Reputation: 2002
I changed the font & size of the UINavigationBar Title, but doing so made the title not align properly anymore so I thought this "setTitlePositionAdjustment:"
should work but it does not (unrecognized selector). How do I adjust the title´s position?
[[UINavigationBar appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[NSValue valueWithUIOffset:UIOffsetMake(0, -1)],
UITextAttributeTextShadowOffset,
[UIFont fontWithName:@"Cochin-Bold" size:24.0],
UITextAttributeFont,
nil]];
[[UINavigationBar appearance] setTitlePositionAdjustment:UIOffsetMake(0, 10)]; // Crash
Upvotes: 3
Views: 2447
Reputation: 5226
You need to call the method setTitleVerticalPositionAdjustment:forBarMetrics: instead.
For example:
[[UINavigationBar appearance] setTitleVerticalPositionAdjustment:10.0 forBarMetrics:UIBarMetricsDefault];
Check the UINavigationBar class reference for more details on the method.
Upvotes: 6