Changing navigation title programmatically

You change the title by changing the title of the view controller being displayed: viewController.title = “some title” Normally this is done in view did load on the view controller: override func viewDidLoad() { super.viewDidLoad() self.title = “some title” } However, this only works if you have your view controller embedded in a UINavigationController. I … Read more

UINavigationBar’s drawRect is not called in iOS 5.0

Setting custom background for UINavigationBar to support iOS5 and iOS4 too! http://www.mladjanantic.com/setting-custom-background-for-uinavigationbar-what-will-work-on-ios5-and-ios4-too/ http://rogchap.com/2011/06/21/custom-navigation-bar-background-and-custom-buttons/ As you know, until iOS 5 came out, we used drawRect override in AppDelegate to customize UINavigationBar. But know, iOS 5 give us some new method for styling (and old doesn’t work). How to build app that will work on iOS 4 … Read more

Real time blur effect for Navigation Bar

Apple has introduced new classes UIVisualEffectView and more to add translucency and blur effect on views from iOS 8.0 release. Here how you can use it to add a blur effect to navigation bar or any other UIView: Swift 5 func addBlurEffect() { let bounds = self.navigationController?.navigationBar.bounds let visualEffectView = UIVisualEffectView(effect: UIBlurEffect(style: .light)) visualEffectView.frame = … Read more

How to add background image on iphone Navigation bar?

Here’s the code from the link @luvieere mentioned. Paste this code into to the rootview controller just above @implementation rootviewController @implementation UINavigationBar (CustomImage) – (void)drawRect:(CGRect)rect { UIImage *image = [UIImage imageNamed:@”NavigationBar.png”]; [image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)]; } @end As of iOS 5, there is an official way to do this. (see iOS Developer Library) // … Read more

How to enable back/left swipe gesture in UINavigationController after setting leftBarButtonItem?

You need to handle two scenarios: When you’re pushing a new view onto the stack When you’re showing the root view controller If you just need a base class you can use, here’s a Swift 3 version: import UIKit final class SwipeNavigationController: UINavigationController { // MARK: – Lifecycle override init(rootViewController: UIViewController) { super.init(rootViewController: rootViewController) delegate … Read more