I have a main view controller with a tableview and a detail view controller to display details about the selected item. I have a nav bar that inserts a back button when user segues to detail screen. On this detail screen, I have a container view that can show other view controllers on the bottom half of the screen. When user brings up a subview, I want to replace the standard back button with my custom button that just resigns the subview, not going back to main view controller. Once the subview is gone, the back button should revert back to stock back button that will go back to main view controller when pressed.
My issue is that I'm having trouble making the back buttons appear the same so user doesn't know I'm using different buttons to achieve these different things. What is the best way to do this? I can't get the text to match up, is an image the better way to go?
Currently in prepareForSegue in main view controller:
// setting nav button text to "<" which is default when no text
let backItem = UIBarButtonItem()
backItem.title = ""
navigationController?.navigationBar.tintColor = UIColor.whiteColor()
navigationItem.backBarButtonItem = backItem
Currently in detail view controller:
func createCustomBackButton() {
self.navigationItem.hidesBackButton = true
let customFont = UIFont(name: "HelveticaNeue", size: 30.0)!
UIBarButtonItem.appearance().setTitleTextAttributes([NSFontAttributeName: customFont], forState: UIControlState.Normal)
customBackButton = UIBarButtonItem(title: "<", style: .Plain, target: self, action: "back:")
self.navigationItem.leftBarButtonItem = customBackButton
}
Any help is greatly appreciated, thanks in advance!!