How to change navigationBar height in iOS 11?
Apparently changing the navigationBar height faced a new approach in iOS 11.
in previous iOS versions it was possible to change the navigationBar height by hiding the default navigationBar and adding a new one with custom frame:
self.navigationController?.setNavigationBarHidden(true, animated: false) let customNavigationBar = UINavigationBar(frame: CGRect(x: 0, y: 0, width: self.view.bounds.width, height: 64)) self.view.addSubview(customNavigationBar)
But it seems that it is not working in iOS 11 xCode beta. no matter the what the new height is, it will always stay at 44.
this is what I’ve got in xCode 9:
does anyone knows how to solve the problem?
- how to localize label strings in ios for a beginner
- What's the difference between setBackgroundImage:Forstate and setImage:Forstate:
- Https iOS with self signed certificate
- @IBDesignable error: IB Designables: Failed to update auto layout status: Interface Builder Cocoa Touch Tool crashed
- Retrieve data from plist
- How to use NSURLSessionDataTask in Swift
2 Solutions Collect From Internet About “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:
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.
The only way I could make it work was to delete the current custom Navigation Bar, and apply an embed UINavigationController to the UIViewController.
Editor -> Embed In -> Navigation Controller.
On the new created Navigation Controller properties, on the Utilities (right side bar) menu ‘Simulated Metrics’ the ‘Top Bar’ attribute must be specified. In my case I needed the value: ‘Opaque Navigation Bar’.
I also set the same value of ‘Top Bar’ on my UIViewController, just to make sure.
By doing that, a new ‘Navigation Item’ will be at your disposal, and you can re-add your Bar Button Items.
It’s the best I could do while we wait for the Xcode 9 update to fix it.
- How can I make a UINavigationController's UINavigationBar invisible or at least change color
- Is it possible to use iOS 7's modified Helvetica in apps?
- Getting the Value of a UITextField as keystrokes are entered?
- How to set a UILabel in UICollectionViewCell
- heightForRowAtIndexPath crashing intermittently
- Is there any way access manufacturer data from iOS device
- NSNumberFormatter with comma decimal separator
- Timestamped Event Matching Error: Failed to find matching element
- MPMoviePlayerController does not work with movie in documents folder
- iOS 11 search bar in tableViewHeader jumps to the top of the screen on focus
- making a scrollview lock on a sprite and enlarging it
- In UITableView, what's the delegate for “visibleCells”?
- Property 'managedObjectStore' not found on object of type 'RKObjectManager'
- Google Cloud Messaging with Xcode 7 and iOS 9
- disable scrolling in a UITableView (iPhone SDK 3.0)