景观视图问题与导航栏

问题描述 投票:2回答:1

默认导航栏高度为64.但更改后,它的方向为横向导航栏高度更改为28.我想设置修复导航栏大小的所有方向。

ios swift uinavigationbar xcode9 ios-autolayout
1个回答
1
投票

您可以添加方向观察器:

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)
}
© www.soinside.com 2019 - 2024. All rights reserved.