0
我正在設置自定義的UIBarButtonItem,它適用於iOS 7但適用於iOS 8我正在看到顯示在當前可見頁面上的分頁中的下一個視圖控制器的背部圖標。我在UIScrollView中有多個視圖控制器。自定義UIBarButtonItem在iOS8中無法正常工作
請參閱下面的代碼。如果我嘗試去除負片,它會正常工作,但後面的圖標移動到右側,看起來不太好。
請提供想法。
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];