What about
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(5, 0) forBarMetrics:UIBarMetricsDefault];
Question
How can I add a space between the background image of the Navigation and the Text in IOS 7. For IOS 6, adding a space make the text at the correct place.
Navbar from IOS 6 :
Navbar from IOS 7 :
My code in AppDelegate to redefine all back buttons :
// Change the appearance of other navigation button
UIImage *barButtonImage = [[UIImage imageNamed:@"icon_back_str.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 31, 0, 0)];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:barButtonImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
//Adapt the Text of the Buttons
NSDictionary *normalAttributes = [NSDictionary dictionaryWithObjectsAndKeys: [UIFont fontWithName:@"MyFont" size:20.0], UITextAttributeFont,nil];
[[UIBarButtonItem appearance] setTitleTextAttributes:normalAttributes forState:UIControlStateNormal];
In my code, to set the text :
- (void) viewWillDisappear:(BOOL)animated {
self.navigationItem.title = @" Zurück";
}
How can Add this space in IOs 7. Thanks.
Solution
What about
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(5, 0) forBarMetrics:UIBarMetricsDefault];