Can anyone advise me on how the border below the navigation bar can be changed?
I would like to change it from the current black light to a softer color. Appreciate any help here
Can anyone advise me on how the border below the navigation bar can be changed?
I would like to change it from the current black light to a softer color. Appreciate any help here
I found a couple of issues with the previous answers:
One way of solving this would be to use autolayout:
The reason why I return the border is that during rotation you do see it in the middle of the
navigation bar
, so I hide it during the rotation.You can also add a child view to your nav bar
The following code will add a 4 pixel deep blue border below your navigation bar
For iOS 7 you could use this:
I do not think there is a method to change the border color of the navigation color, other than the
tintColor
property of theUINavigationBar
.I would suggest that you create a UIView of that border size and place it below the navigation bar / add it as a
subView
.Despite navigationBar is read-only property for UINavigationController you can avoid this restriction by "setValue:forKey:". This method was approved on 5 applications successfully submitted to AppStore.
You can subclass UINavigationBar and change drawRect: method as you want. For example,
After you can subclass UINavigationController and change initWithRootViewController:
Also you can vary this approach by making Category for UINavigationController and implementing method swizzling for initWithRootViewController:
P.S. Yesterday my new app appeared at AppStore without any problem with this approach.
In Swift like the @Legolas answer:
You can put in the
viewDidLoad()
of yourUIViewController
.