How can I change height of Navigation Bar - Swift 3
UPDATE 8/3/20: I posted this in 2016. A number of people have stated this no longer works so please use at your own risk. I am not working in iOS at the moment so I do not have an update handy. Best of luck!
Here is one way to do it:
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let height: CGFloat = 50 //whatever height you want to add to the existing height
let bounds = self.navigationController!.navigationBar.bounds
self.navigationController?.navigationBar.frame = CGRect(x: 0, y: 0, width: bounds.width, height: bounds.height + height)
}
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.
Change height of navigation bar ios
The hierarchy of UINavigationBar view is private so we can't manipulate it.We create our custom view and add into a Viewcontroller.
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
}
Related Topics
Xcode 4.5 and iOS 4.2.1 Incompatibility
iPad Remembering Camera Permissions After Delete-How to Clear
Class Amsupporturlconnectiondelegate Is Implemented in Both
Counting the Number of Lines in a Uitextview, Lines Wrapped by Frame Size
Is Silent Remote Notifications Possible If User Has Disabled Push for the App
iOS 8 Enabled Device Not Receiving Push Notifications After Code Update
Location Services Not Working in iOS 11
App Rejected Because of "Missing Push Notification Entitlement"
Required Ipv6 Compatibility - iOS App Rejected by Apple
In iOS, How to Store a Secret "Key" That Will Allow Me to Communicate with My Server
Iphone: How to Get Current Milliseconds
How to Dismiss the Keyboard When Editing a Uitextfield
Wrong Color in Interface Builder
Select Multiple Images (Uiimagepickercontroller or Photos.App Share Ui)