title: Build Toolbar programmatically
body: <p>I'm learning how to use Swift, and I realized that I can't add a toolbar directly into a storyboard with a <code>UITableViewController</code>, so I'm struggling trying to add it programmatically.</p>
  
  <p>This is what I'm trying to make it look like:</p>
  
  <p><img src="https://i.stack.imgur.com/pB6Tom.png" alt="iOS screenshot"></p>
  
  <p>Now, I added this code: </p>
  
  <pre><code>    let homeButton = UIBarButtonItem(title: "H", style: .plain, target: self, action: #selector(ProfileButtonTapped))
  
      let addButton = UIBarButtonItem(title: "+", style: .plain, target: self, action: #selector(ProfileButtonTapped))
  
  let loveButton = UIBarButtonItem(title: "Love", style: .plain, target: self, action: #selector(ProfileButtonTapped))
  
  let arr: [Any] = [homeButton, addButton, loveButton]
  setToolbarItems(arr as? [UIBarButtonItem] ?? [UIBarButtonItem](), animated: true)
  super.viewDidAppear(animated)
  </code></pre>
  
  <p>And it looks like this:</p>
  
  <p><img src="https://i.stack.imgur.com/laN2mm.png" alt="iOS screenshot"></p>
  
  <p>But I can`t find a way to make it look with the same spacing as the original, and also If I set the image I didn't find a way to adapt the size as I need it. </p>
  
  <p>I tried using this code that I found here and seemed to work, but when I load my app, it simply shows the bar without any element.</p>
  
  <pre><code>navigationController?.setToolbarHidden(false, animated: true)
  
  let homeButn = UIImage(named: "HomeButton")
  
  let zeroPoint = CGPoint.zero
  let settingsButton = UIButton(type: UIButtonType.custom) as UIButton
  settingsButton.frame = CGRect(origin: zeroPoint, size: CGSize(width: 27, height: 27))
  settingsButton.setImage(homeButn, for: [])
  settingsButton.addTarget(self, action: #selector(ProfileButtonTapped), for: UIControlEvents.touchUpInside)
  
  let rightBarButtonItem = UIBarButtonItem(customView: settingsButton)
  navigationItem.setRightBarButton(rightBarButtonItem, animated: true)
  </code></pre>
  
  <p>I don't really know how to do this, any ideas? Thanks a lot!</p>