Here is what I have in my viewDidLoad method:
self.navigationController?.navigationBar.backIndicatorImage = UIImage(named: "back")
self.navigationController?.navigationBar.backIndicatorTransitionMaskImage = UIImage(named: "back")
self.navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: UIBarButtonItemStyle.Plain, target: nil, action: nil)
I am trying to have a custom icon image for my back button in my navigation controller. Instead of the image showing in it's original format, I am seeing the image in blue. How do I get the image to show properly?
You can use renderingMode
for your custom image with AlwaysOriginal
mode. See below code for solved it.
self.navigationController?.navigationBar.backIndicatorImage = UIImage(named: "back")?.imageWithRenderingMode(.AlwaysOriginal)
self.navigationController?.navigationBar.backIndicatorTransitionMaskImage = UIImage(named: "back")?.imageWithRenderingMode(.AlwaysOriginal)
Hope that helps!
Quickest solution
.navigationController?.navigationBar.tintColor = UIColor.redColor()
Or you can create custom barButton item, with custom view
Set the tintColor property of the barbuttonItem.
self.navigationItem.backBarButtonItem.tintColor = "any color"