如何创建和更改尺寸高度导航栏iOS 11
How to create and change size height navigation bar iOS 11
它们不起作用!
// Add bar button item
override func viewDidLoad() {
super.viewDidLoad()
var customBar: UINavigationBar = UINavigationBar()
title = "Some Title"
self.customBar.frame = CGRect(x:0, y:0, width:view.frame.width, height:(navigationController?.navigationBar.frame.height)! + 50)
self.customBar.backgroundColor = UIColor.green
self.view.addSubview(customBar)
}
感谢帮助!!!
我认为您无法更改它 - 不再受支持。这是来自 Apple staff
的引述
Resizing the navigation bar (via any method, including subclassing) is
not supported, and neither is changing the frame of a navigation bar
that is owned by a UINavigationController (the navigation controller
will happily stomp on your frame changes whenever it deems fit to do
so). The navigation bar needs to be placed on the bottom edge of
the status bar, not underlapping the status bar, and with its natural
height.Finally, the internal layout of the
navigation bar is an implementation detail including all class names
and orderings. Any code that relies upon the ordering of the
navigation bar's subviews or the names of any of their classes is
likely to encounter issues in the future, as these are all private
details. Please do not rely upon them. If there are things you want to
do with a navigation bar that you cannot
四处走动就是使用图像视图然后改变它的高度。
它们不起作用!
// Add bar button item
override func viewDidLoad() {
super.viewDidLoad()
var customBar: UINavigationBar = UINavigationBar()
title = "Some Title"
self.customBar.frame = CGRect(x:0, y:0, width:view.frame.width, height:(navigationController?.navigationBar.frame.height)! + 50)
self.customBar.backgroundColor = UIColor.green
self.view.addSubview(customBar)
}
感谢帮助!!!
我认为您无法更改它 - 不再受支持。这是来自 Apple staff
的引述Resizing the navigation bar (via any method, including subclassing) is not supported, and neither is changing the frame of a navigation bar that is owned by a UINavigationController (the navigation controller will happily stomp on your frame changes whenever it deems fit to do so). The navigation bar needs to be placed on the bottom edge of the status bar, not underlapping the status bar, and with its natural height.Finally, the internal layout of the navigation bar is an implementation detail including all class names and orderings. Any code that relies upon the ordering of the navigation bar's subviews or the names of any of their classes is likely to encounter issues in the future, as these are all private details. Please do not rely upon them. If there are things you want to do with a navigation bar that you cannot
四处走动就是使用图像视图然后改变它的高度。