Below is the code using UIButton with image, you can add it as a custom view for UIBarButtonItem
override func viewDidLoad() { super.viewDidLoad() var backbutton = UIButton(type: .Custom) backbutton.setImage(UIImage(named: "BackButton.png"), forState: .Normal) // Image can be downloaded from here below link backbutton.setTitle("Back", forState: .Normal) backbutton.setTitleColor(backbutton.tintColor, forState: .Normal) // You can change the TitleColor backbutton.addTarget(self, action: "backAction", forControlEvents: .TouchUpInside) self.navigationItem.leftBarButtonItem = UIBarButtonItem(customView: backbutton) } func backAction() -> Void { self.navigationController?.popViewControllerAnimated(true) }
Download link
To set the button title with the previous title of the view controller, you must pass the title as a string, presenting the controller, changing the code above as.
var titleStrFromPreviousController: String
This can help.
Swift 3
override func viewDidLoad() { super.viewDidLoad() addBackButton() } func addBackButton() { let backButton = UIButton(type: .custom) backButton.setImage(UIImage(named: "BackButton.png"), for: .normal) // Image can be downloaded from here below link backButton.setTitle("Back", for: .normal) backButton.setTitleColor(backButton.tintColor, for: .normal) // You can change the TitleColor backButton.addTarget(self, action:
source share