我的应用程序已经在应用商店中,昨天我已经将我的 Xcode 版本更新到 9 并且除了iPhone x之外工作正常。UI 崩溃了。
1.在这里,我创建了两个UIView(都是固定高度),分别命名为 Header 和 Tab bar,并且我隐藏了NavigationBar整个应用程序。
2.为UIViewController添加扩展,用于制作Header和Tab bar
func addHeaderTab(currentViewController:UIViewController,content:String, isMenu:Bool){
let noView = TopHeaderView()
noView.tag = 12345
noView.isMenu = isMenu
noView.translatesAutoresizingMaskIntoConstraints = false
currentViewController.view .addSubview(noView)
if isMenu{
noView.menuBtn .setImage(UIImage(named: "Small"), for: .normal)
noView.logoImg.isHidden = false
}else{
noView.menuBtn .setImage(UIImage(named: "arrow_small"), for: .normal)
noView.logoImg.isHidden = true
}
noView.titleLbl.text = content
noView.delegate = (currentViewController as! menuOpen)
NSLayoutConstraint(item: noView, attribute: .leading, relatedBy: .equal, toItem: currentViewController.view, attribute: .leading, multiplier: 1.0, constant: 0.0).isActive = true
NSLayoutConstraint(item: noView, attribute: .trailing, relatedBy: .equal, toItem: currentViewController.view, attribute: .trailing, multiplier: 1.0, constant: 0.0).isActive = true
NSLayoutConstraint(item: noView, attribute: .top, relatedBy: .equal, toItem: currentViewController.view, attribute: .top, multiplier: 1.0, constant: 0.0).isActive = true
NSLayoutConstraint(item: noView, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .height, multiplier: 1.0, constant: 64).isActive = true
}
并像下面这样调用每个Viewcontroller:
self.addHeaderTab(currentViewController: self, content:"நிகழ்ச்சி நிரல்" , isMenu: true)
就像那个标签栏一样,我也做过,但所有设备都可以正常工作,但需要iPhone x。
请参阅我的屏幕截图:
我研究过https://developer.apple.com/ios/human-interface-guidelines/overview/iphone-x/
但不清楚他们的文件。
帮助将不胜感激,在此先感谢。