ios - 导航栏的横向 View 问题

标签 ios swift uinavigationbar xcode9 ios-autolayout

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

相关文章:

ios - 带有自定义单元格的 TableView。当单元格滚动(双端队列)时,它们会以混合的 UIView 颜色重新出现。我可以在indexPath.row处设置UIView吗?

swift - 在 SpriteKit 中创建随机数

Swift 如何更改 backIndicatorImage 的位置和大小

swift - 如何在保持导航栏存在的同时以模态方式呈现 View Controller 。 (对于设置 View Controller )

ios - UIScrollView: addSubview 不添加项目

ios - 使用 Storyboard instantiateviewcontrollerwithidentifier 在 tableView 之间传递数据

ios - 已调用 Dealloc 但未释放内存

ios - DispatchQueue.main.async如何存储它的 block

arrays - 字符串数组顺序错误

ios - 在半透明导航栏下查看?