Cant change navigation bar height ios 11
Changing the height of the UINavigationBar is no longer directly supported in iOS 11 (see here, here & here).
The best you can hope for is to do something like having a view behind the navigation bar and removing the borders (see here for customisation examples).
Cannot change navigation bar item height in iOS 11
You can change the width of navigation bar button item by using this code -
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
var frame: CGRect? = navigationItem.leftBarButtonItem?.customView?.frame
frame?.size.width = 5 // change the width of your item bar button
self.navigationItem.leftBarButtonItem?.customView?.frame = frame!
}
override var prefersStatusBarHidden : Bool {
return true
}
Or from storyboard -
Make sure your Assets.xcassets
image is set as Render As - Original
Image Just like -
How to change navigationBar height in iOS 11?
Your code is working fine and it´s nothing wrong with it. If you change the background color of your customNavigationBar
you´ll see that you´ll get the navigation bar with the desired height. But it seems like it´s an issue with Xcode 9 to hide the default navigation bar.
Your code with:
Xcode 9
Xcode 8
As you can see in the Xcode 9 image, you have the custom navigation bar but the default one does not hide. Probably a bug in Xcode 9, I did not manage to hide it through the Storyboard either.
This seems to be a bug in Xcode 9, bug reports has been filed to Apple.
Related Topics
iOS Document/File Type Associations - Wildcard Uti
Programmatically Checking If a Passcode Lock Is Set
Xcode Creates Wrong IPA Folder Structure
Taking Photo with Custom Camera Swift 3
Get the Expiration Date of a Provisioning Profile at Run-Time
How to Create Scrollable Table in Skspritekit
Refresh Only the Custom Header Views in a Uitableview
Programmatically Added Constraint Not Working
How to Play Multiple Audio Files Simultaneously
How to Calculate Current Location in Watchkit Extension
Cgcontextsetfillcolorwithcolor: Invalid Context 0X0
How to Recover After I Execute :Git Reset --Hard Head
Swift- Custom Uitableviewcell Delegate to Uiviewcontroller Only One Protocol Works
iOS Multiple Right and Left Align on Same Line
How to Use Store and Use an Nsmutableattributedstring in Nsuserdefaults