Ever since iOS 6 I have several problems with using custom styling in my application. I use a custom font and several UIAppearance
proxies. A problem I can\'t g
If it helps, you can adjust (at least) the vertical position of the title:
[[UINavigationBar appearance] setTitleVerticalPositionAdjustment:4 forBarMetrics:UIBarMetricsDefault];
(This question helped me to find a solution to this problem: UINavigationBar custom title position )
Same issue here, but I noticed it doesn't happen when the navigation bar has either a back button or a right bar button (table edit). The alignment on the title is also fixed when navigating to a new view controller and then going back to the first one...
What I think that is happening is that iOS calculates the position of the frame of the title based on the default font, because the font I use is a bit smaller the title misaligns a bit to the left of the center.
My current fix is calling setNeedsLayout
in viewWillAppear. Seems to be working.
- (void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
if (self.navigationItem.hidesBackButton || self.navigationItem.rightBarButtonItem == nil) {
[self.navigationController.navigationBar setNeedsLayout];
}
}