IOS - 后退按钮IOS6与IOS7

时间:2014-05-15 14:31:23

标签: ios objective-c

如何在导航的背景图像和IOS 7中的文本之间添加空格。对于IOS 6,添加空格可使文本位于正确的位置。

IOS 6的Navbar:

Navbar from IOS 6 :

IOS 7的Navbar:

Navbar from IOS 7 :

我在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.谢谢。

1 个答案:

答案 0 :(得分:6)

怎么样?
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(5, 0) forBarMetrics:UIBarMetricsDefault];