あなたはUINavigationBarをサブクラス化することができます
class CustomNavigationBar: UINavigationBar {
override func sizeThatFits(_ size: CGSize) -> CGSize {
let newSize :CGSize = CGSize(width: self.frame.size.width,height: 84)
return newSize
}
}
そして、ナビゲーションコントローラを作成し、カスタムナビゲーションバーのクラスを使用するように初期化子を使用しています。
let nav = UINavigationController(navigationBarClass:CustomNavigationBar.self,toolbarClass: nil)
UINavigationBarの既存の動作はすべて保持され、カスタム高さが採用されます。
OR
あなたはすでに試したのように:
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let height: CGFloat = 84 //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)
}
OR: あなたはナビゲーションbar.Thisを置き換えるためにカスタムビューを使用することができますChanging the height of the Navigation bar iOS Swift
44(navigationBar高さ)+ 20(ステータスバーの高さ)= 64は、標準的なものです。 –