I have a simple storyboard containing a navigation controller with a static table view controller. I have added a view controller and connected it to one of the cells via a push segue. One thing I have noticed is that the navigation bar title doesn't center properly vertically with the back button and UIBarButtonItem
.
Here is an image of what it looks now.
Notice that it is all aligned to the bottom. What I want is, is a way to either move the title down or move the buttons up. If the buttons were moved up, the back button arrow should be moved as well, and allow to return to the main table view.
Here is the code I'm using to set the UIBarButtonItem
font in the view controller (If it helps) :
[clearButton setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@"ChalkboardSE-Regular" size:15], NSFontAttributeName, [UIColor whiteColor], NSForegroundColorAttributeName, nil] forState:UIControlStateNormal];
And here is what I'm using to set the font for the back button in the app delegate, didFinishLaunchingWithOptions:
:
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor], NSFontAttributeName:[UIFont fontWithName:@"ChalkboardSE-Regular" size:15]}forState:UIControlStateNormal];
You can move the title down using: [[UINavigationBar appearance] setTitleVerticalPositionAdjustment:(float) forBarMetrics:UIBarMetricsDefault];
SWIFT version for iOS 8+
self.navigationController!.navigationBar.setTitleVerticalPositionAdjustment(adj, forBarMetrics: .Default)
self
is a UIViewController:Note: Consider specifying adjustments for the other bar metrics options, to refine the offset for landscape mode and compact devices, because one offset may not look right on all phones in all positions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With