I have simple project inside im using UINavigationBar
inside UIImageView
logo but some views my logo looking 30-40px
right side or some views looking 50-60px
left side.
How to set navigationItem.titleView image horizontal center?
My code is below:
navigationController!.navigationBar.barTintColor = UIColor.clearColor()
navigationController!.navigationBar.tintColor = UIColor.whiteColor();
let imageView = UIImageView(frame: CGRect(x: 50, y: 0, width: 164, height: 38))
imageView.contentMode = .ScaleAspectFit
let image = UIImage(named: "logo.png")
imageView.image = image
navigationItem.titleView = imageView
Output picture:
Also when I change x:50
to x:80
or x:0
etc., nothing happened!
you can set x origin 0 like
let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 164, height: 38))