I\'m using an image view to display an image in my nav bar. The problem is that I can\'t set it to the center correctly because of the back button. I checked the related que
1) You can try setting your image as UINavigationBar's background image by calling
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"color.png"] forBarMetrics:UIBarMetricsDefault];
inside the viewDidLoad
method.
That way it will be always centered, but if you have back
button with long title as left navigation item, it can appear on top of your logo. And you should probably at first create another image with the same size as the navigation bar, then draw your image at its center, and after that set it as the background image.
2) Or instead of setting your image view as titleView
, you can try simply adding at as a subview, so it won't have the constraints related to right and left bar button items.