【发布时间】:2014-09-25 20:28:11
【问题描述】:
我正在设置一个自定义 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];
【问题讨论】:
标签: ios cocoa-touch uiscrollview uibarbuttonitem