"; self.navigation...">

UIBarButtonItem will always stand out when I click on it

- (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];
}

The top right UIBarButtonItem is always highlighted:

image

Why is the UIBarButtonItem "我 会 变灰" always highlighted in the upper right corner? Is this a bug in iOS 11.2?

+4
source share
1 answer

Is this a bug in iOS 11.2?

Yes. There is an iOS 11 error with a right-click panel item in the root view controller. When you move to the next view controller and mute, the right-panel pane button is darkened.

This is a mistake observed in your screencast. In your code, you set the hue color of the right panel button to white. And initially it is white. But when you click and then pop, it is no longer white.

viewWillAppear :

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

Source: https://habr.com/ru/post/1690751/


All Articles