I am trying to create my own Navigation Controller class so that I can use wherever I want with the same customized properties. To achieve that I tried to implement new navigation controller class that inherits from UINavigationController. With customized code I was able to change the background image but I could not create custom bar button item.
Below you can see my custom navigation controller.
//Some navigation properties to be customized
let navBar = self.navigationBar
let navItem = self.navigationItem
//Background image creation
let image = UIImage(named: "usttab.jpg")
//Assigning background image
navBar.setBackgroundImage(image, forBarMetrics: .Default)
//Customizing navigation item
navItem.backBarButtonItem = UIBarButtonItem(title: "Geri", style: UIBarButtonItemStyle.Plain, target: nil, action: nil)
Short of the long story my back button's title does not change.
With assigning back bar button item property in the view controllers separately but it does not make sense to copy paste same code to every view controller. Thus, I want to create my own navigation controller class to use anywhere I want.
Please let me know if you need further information about my code.
Thanks,
If you are setting the same properties across multiple subclasses of UIViewController, you can create a base subclass of UIViewController and subclass that base subclass. This will allow those properties to be shared and allows you to avoid repeating code.