如何在导航的背景图像和IOS 7中的文本之间添加空格。对于IOS 6,添加空格可使文本位于正确的位置。
IOS 6的Navbar:
IOS 7的Navbar:
我在AppDelegate中的代码重新定义了所有后退按钮:
// 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];
在我的代码中,设置文字:
- (void) viewWillDisappear:(BOOL)animated {
self.navigationItem.title = @" Zurück";
}
如何在IO中添加此空间7.谢谢。
答案 0 :(得分:6)
怎么样?
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(5, 0) forBarMetrics:UIBarMetricsDefault];