升級iOS 11和Swift 4(Xcode 9)後,我遇到了很多UI問題。 :(
最無法解決的問題是導航問題。
我把導航欄UICollectionView控制器。
導航欄高度不正確顯示和但是我寫的代碼。
在UICollectionView中添加導航欄在iOS 4中,iOS 11
我設置導航欄的高度「 100" 。我寫這篇文章的代碼viewDidLoad中()。
if #available(iOS 11.0, *) {
print("IOS 11 Screen")
UINavigationBar.appearance().largeTitleTextAttributes = [
NSForegroundColorAttributeName: UIColor.white,
]
navigationItem.largeTitleDisplayMode = .never
let height: CGFloat = 100 //whatever height you want
let bounds = self.navigationController!.navigationBar.bounds
self.navigationController?.navigationBar.frame = CGRect(x: 0, y: 0, width: bounds.width, height: bounds.height + height)
} else {
print("lower than IOS 11 Screen")
// Fallback on earlier versions
}
collectionview?.frame = CGRect(x: 0, y: 10, width: UIScreen.main.bounds.width, height: (UIScreen.main.bounds.height + 20)) <br>
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let height: CGFloat = 100 //whatever height you want
let bounds = self.navigationController!.navigationBar.bounds
self.navigationController?.navigationBar.frame = CGRect(x: 0, y: 0, width: bounds.width, height: bounds.height + height)
}
override func viewWillAppear(_ animated: Bool) {
let height: CGFloat = 100 //whatever height you want
let bounds = self.navigationController!.navigationBar.bounds
self.navigationController?.navigationBar.frame = CGRect(x: 0, y: 0, width: bounds.width, height: bounds.height + height)
}
不過,我試着用這個代碼。沒有爲我工作。
我還試圖打開源代碼視圖故事板,我編輯導航欄的高度。但是,這也行不通。
任何人都可以幫助我嗎?自過去兩天以來,我一直試圖解決這個問題。
我不認爲你可以調整導航欄的高度。相反,您可以創建一個自定義導航欄,同時覆蓋系統給出的導航欄。 – antonio081014