title: How to programmatically create a "Back" UIBarButton item in Swift?
body: <p>I was able to create a UIBarButton item that can go back programmatically using the following code:</p>
  
  <pre><code>    func backAction() -&gt; Void {        
          self.navigationController?.popViewControllerAnimated(true)
      }
  override func viewDidLoad() {
          super.viewDidLoad()
      let backButton = UIBarButtonItem(title: "Back", style: UIBarButtonItemStyle.Plain, target: self, action: "backAction")
  
          self.navigationItem.leftBarButtonItem = backButton
      }
  </code></pre>
  
  <p>The problem is that the back button doesn't have the left pointing arrow: 
  <a href="https://i.stack.imgur.com/3Ox0R.png" rel="noreferrer"><img src="https://i.stack.imgur.com/3Ox0R.png" alt="enter image description here"></a>
  Is there a way to make it look like a regular back button with the arrow like this: <a href="https://i.stack.imgur.com/3fKw8.png" rel="noreferrer"><img src="https://i.stack.imgur.com/3fKw8.png" alt="enter image description here"></a></p>
  
  <p>I would also like to know if there is a way to make the button title names as the title of the previous view controller, if that's possible.</p>
  
  <p>Thanks</p>