我正在设定 self.navigationItem.rightBarButtonItem = self.editButtonItem; 在viewDidLoad中 这适用于iOS< 7我在下面,为什么不以标题为中心?我做错了什么?
当有一个后退按钮并且至少没有点击一次时我得到:
点击后我得到:
按钮的背景在app delegate中设置:
// Change the appearance of back button
UIImage *backButtonImage = [[UIImage imageNamed:@"backbtn"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 13, 0, 6)];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
// Change the appearance of other navigation button
UIImage *barButtonImage = [[UIImage imageNamed:@"btn"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 6, 0, 6)];
[[UIBarButtonItem appearance] setBackgroundImage:barButtonImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
答案 0 :(得分:0)
iOS7下的导航存在同样的问题......
得到了几个答案here and there,但它们似乎没有帮助。 如果您使用UINavigationBar的backIndicatorImage,它会粘在顶部,我不知道如何修复它。
我最终做了建议的here
像这样创建一个UIBarButtonItem:
UIBarButtonItem* backBtn = [[UIBarButtonItem alloc] initWithTitle:@"Back"
style:UIBarButtonItemStylePlain
target:self
action:@selector(backButtonAction:)];
backBackgroundImage = [UIImage imageNamed: @"back_btn"];
backBackgroundImage = [backBarButtonBackground resizableImageWithCapInsets:
UIEdgeInsetsMake(0.0, 14.0, 0.0, 5.0)];
[backBtn setBackgroundImage:backBackgroundImage
forState:UIControlStateNormal
barMetrics:UIBarMetricsDefault];
[backBtn setTitlePositionAdjustment:UIOffsetMake(5, 0) forBarMetrics:UIBarMetricsDefault];
然后将其用作导航控制器上的后退按钮。