title: How to center an image in navigationBar across all UIViewControllers? Swift / Obj-C
body: <p>Problem visually:</p>
  
  <p><a href="https://i.stack.imgur.com/ZXiwW.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ZXiwW.png" alt="Logo is centered in the empty space, not in the navigationBar"></a></p>
  
  <p>I have tried putting the image in the center of its own frame with no luck. I have also tried to center it with playing the <code>x</code> of the CGRect with no luck either. I presume I can just put an empty icon with the same background as the navigation bar; however, I don't want to do it that way. I might have 2-3 icons on the right; then what?</p>
  
  <pre><code>    let image = UIImage(named: "some_logo")!
      let imageSize = CGSizeMake(60, 42)
      let marginX: CGFloat = (self.navigationController!.navigationBar.frame.size.width / 2) - (imageSize.width / 2)
      let imageView = UIImageView(frame: CGRect(x: marginX, y: 0, width: imageSize.width, height: imageSize.height))
      imageView.image = image
      imageView.contentMode = .ScaleAspectFit
  
      self.navigationItem.titleView = imageView
  </code></pre>
  
  <p>I prefer swift but obj-c solutions are welcomed as well.</p>
  
  <p>Any pointers appreciated.</p>
  
  <p>This app has nothing to do with KIA, it is just some logo I got off the google search, searching "some logo".</p>