我正在设置一个自定义的UIBarButtonItem,它适用于iOS 7但是在iOS 8中,我看到我的下一个视图控制器的后退图标显示在当前可见页面上。我在UIScrollView中有多个视图控制器。
请参阅下面的代码。如果我尝试移除负片垫片,它可以正常工作但后面的图标移动到右侧并且看起来不太好。
请提供意见。
UIImage *backArrow = [UIImage imageNamed:@"back.png"];
UIButton *aBackButton = [UIButton buttonWithType:UIButtonTypeSystem];
CGSize aBackButtonTextSize = [MyLocalized(BackButtonKey) sizeWithFont:[UIFont systemFontOfSize:kFontSize17]];
aBackButton.frame = CGRectMake(kScreenOrigin, kScreenOrigin, aBackButtonTextSize.width + backArrow.size.width, self.navigationController.navigationBar.frame.size.height);
aBackButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
[aBackButton addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
[aBackButton setTitle:MyLocalized(BackButtonKey) forState:UIControlStateNormal];
[aBackButton setImage:backArrow forState:UIControlStateNormal];
UIBarButtonItem *aLeftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:aBackButton];
UIBarButtonItem *aNegativeSpacer = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
aNegativeSpacer.width = -8;
self.navigationItem.leftBarButtonItems = @[aNegativeSpacer, aLeftBarButtonItem];
答案 0 :(得分:0)