【问题标题】:Landscape view issue with navigation bar导航栏的横向视图问题
【发布时间】:2018-08-12 03:51:59
【问题描述】:

默认导航栏高度为 64。但将其方向更改为横向导航栏高度后更改为 28。我想在所有方向上设置固定导航栏大小。

【问题讨论】:

    标签: ios swift uinavigationbar xcode9 ios-autolayout


    【解决方案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)
    }
    

    【讨论】:

    • 感谢响应。仍未解决。@maxwell 导航栏在横向中将高度 44 更改为 32。在该导航栏下方,我放置了高度为 56 的搜索栏。仍然在导航栏和搜索之间显示一些空间横向酒吧
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多