[英]Is there a way to change the height of a UINavigationBar in a UINavigationController Swift Xcode?
Is there a way to change (namely, decrease) the height of a UINavigationBar in a UINavigationController?有没有办法在 UINavigationController 中改变(即减少)UINavigationBar 的高度? I have tried the following to no avail:
我尝试了以下方法无济于事:
extension UINavigationBar {
override open func sizeThatFits(_ size: CGSize) -> CGSize {
return CGSize(width: UIScreen.main.bounds.size.width, height: 10)
}
}
class CustomNavigationController : UINavigationController {
override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
navigationBar.frame.size.height = 10
}
}
Thanks in advance!提前致谢!
Try the below codes,试试下面的代码,
override func viewDidLayoutSubviews()
{
super.viewDidLayoutSubviews()
let height = CGFloat(72)
navigationBar.frame = CGRect(x: 0, y: 0, width: view.frame.width, height: height)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.