导航栏的景观视图问题 [英] Landscape view issue with navigation bar
本文介绍了导航栏的景观视图问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
默认导航栏高度为64.但是将其更改为横向导航栏高度的方向更改为28.我想在所有方向上设置固定导航栏大小".
Default Navigation bar height is 64.But after change it's orientation to landscape navigation bar height changed to 28.I want to set Fix navigation bar size in all orientation.
推荐答案
您可以添加方向观察器:
You can add orientation observer:
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)
}
这篇关于导航栏的景观视图问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文