默认导航栏高度为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)
}