Customizing Navigation Bar in iOS9 with Swift

In this post you will change the background colour, the tint colour and add an image to the Navigation Bar.
Built with iOS 9 and Xcode 7

var navbar = self.navigationController?.navigationBar
navbar?.tintColor = UIColor.whiteColor()
UINavigationBar.appearance().setBackgroundImage(UIImage(named: "barHeader")!.resizableImageWithCapInsets(UIEdgeInsetsMake(0, 0, 0, 0), resizingMode: .Stretch), forBarMetrics: .Default)

navbar?.setBackgroundImage(UIImage(named: "barHeader"), forBarMetrics: .Default)
navbar?.titleTextAttributes = [NSForegroundColorAttributeName : UIColor.whiteColor()]
navbar?.translucent = true

customizing-navigationbar-swift

Leave a Reply

Your email address will not be published.