ios - 当我点击 UIBarButtonItem 时它会一直高亮

标签 ios objective-c ios11 ios11.2

<分区>

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = @"这是个bug?->";
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:68/255.0 green:155/255.0 blue:235/255.0 alpha:1.0];
    self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:[UIColor whiteColor]};

    UIBarButtonItem *rightItem0 = [[UIBarButtonItem alloc] initWithTitle:@"我会变灰" style:UIBarButtonItemStylePlain target:self action:@selector(recordButtonClick)];
    [rightItem0 setTintColor:[UIColor whiteColor]];

    self.navigationItem.rightBarButtonItems = @[rightItem0];
}

- (void)recordButtonClick{
    [self.navigationController pushViewController:[NextViewController new] animated:YES];
}

右上角的 UIBarButtonItem 始终突出显示:

image

为什么右上角的UIBarButtonItem“我会变灰”一直高亮? 这是 iOS 11.2 中的错误吗?

最佳答案

Is it a bug in iOS 11.2?

是的。 Root View Controller 中的右栏按钮项存在 iOS 11 错误。当您推送到下一个 View Controller 并弹出时,右侧栏按钮项目变暗。

这是您在截屏视频中看到的错误。在您的代码中,您将右栏按钮项目的色调颜色设置为白色。最初,它白色的。但是当你插入然后弹出时,它不再是白色的。

我所做的是在 View Controller 的 viewWillAppear 中解决这个问题,如下所示:

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    self.navigationController?.navigationBar.tintAdjustmentMode = .normal
    self.navigationController?.navigationBar.tintAdjustmentMode = .automatic
}

关于ios - 当我点击 UIBarButtonItem 时它会一直高亮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47805224/

相关文章:

ios - 弹出回 UIViewController 后,UIScrollView 的原点发生变化

c# - iPhone 编程 - 印象,意见?

iphone - 为什么这段代码运行缓慢?

mobile-safari - 禁用视口(viewport)缩放 iOS 10+ safari?

objective-c - 解析 .plist 项目

ios - 检索外设与标识符 : What devices will be retrieved by this function?

ios - 如何在 Swift 4.2 中使用 NSPredicate 仅从智能相册中获取图像资源?

debugging - 无线调试图标未显示在我的 Xcode 9 中

ios - 监控 2 个或更多区域时出现 iBeacons 问题

ios - 即使 ios 应用程序在后台调用网络服务