默认导航栏高度为 64。但在将其方向更改为横向导航栏高度后更改为 28。我想在所有方向上设置固定导航栏大小。
最佳答案
您可以添加方向观察器:
NotificationCenter.default.addObserver(self, selector: #selector(rotated), name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil)
并添加旋转方法:
func rotated() {
let height: CGFloat = 50 //whatever height you want to add to the existing height
let bounds = self.navigationController!.navigationBar.bounds
self.navigationController?.navigationBar.frame = CGRect(x: 0, y: 0, width: bounds.width, height: bounds.height + height)
}
关于ios - 导航栏的横向 View 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49094414/