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.
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).
Large navigation bar custom height
Ok, I found this way:
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.minimumLineHeight = 200
let attributes: [NSAttributedString.Key: Any] = [ .paragraphStyle: paragraphStyle]
let navigationBar = navigationController?.navigationBar
if #available(iOS 13, *) {
if let appearance = navigationBar?.standardAppearance {
appearance.largeTitleTextAttributes = attributes
navigationBar?.standardAppearance = appearance
navigationBar?.scrollEdgeAppearance = appearance
}
} else {
navigationBar?.largeTitleTextAttributes = attributes
}
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 -
UISearchBar increases navigation bar height in iOS 11
I got black line under NavigationBar with SearchBar in iOS 11 in two cases:
when i pushed another ViewControllers from ViewController with UISearchBar
when i dismissed ViewController with UISearchBar with "drag right to dismiss"
My solution was: adding this code to my ViewController with UISearchBar:
-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
[self.navigationController.view setNeedsLayout]; // force update layout
[self.navigationController.view layoutIfNeeded]; // to fix height of the navigation bar
}
Swift 4 Update
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
navigationController?.view.setNeedsLayout() // force update layout
navigationController?.view.layoutIfNeeded() // to fix height of the navigation bar
}
Related Topics
How to Create a Delay in Swift
"From View Controller" Disappears Using Uiviewcontrollercontexttransitioning
How to Get the Console Logs from the iOS Simulator
Uitextview That Expands to Text Using Auto Layout
Get Size of a View in React Native
Presenting a Uialertcontroller Properly on an iPad Using iOS 8
Swift 2.0 Calendar Components Error
Undefined Symbols for Architecture X86_64 on Xcode 6.1
How to Recognize Which Pin Was Tapped
Uitableview and Uiview with Keyboardwillshow
Iad Is Shutting Down. Should I Remove the Iad Framework from All My Applications
Update Restkit 'Lcl_Rk.H' File Not Found in Rklog.H
Uitableview Load More When Scrolling to Bottom Like Facebook Application
Behaviour for Significant Change Location API When Terminated/Suspended
Using Multiple Storyboards in iOS
Setneedslayout VS. Setneedsupdateconstraints and Layoutifneeded VS Updateconstraintsifneeded