Я столкнулся с странной ошибкой, которая происходит только на iOS 10.
У меня есть приложение с несколькими экранами, и каждый экран раскрашивает navigationBar
в viewWillAppear
. Поэтому, когда вы переходите к следующему экрану, он будет правильно окрашен.
Однако при тестировании на iOS 10 я неожиданно вижу следующее поведение при возвращении к предыдущему экрану:
Когда появится предыдущий экран, navigationBar
по-прежнему имеет цвет предыдущего экрана, а затем мигает до нужного цвета.
Он почти выглядит как viewWillAppear
как-то ведет себя как viewDidAppear
.
Соответствующий код:
ViewController:
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[ViewControllerPainter paint:self withBackground:[UIColor whiteColor] andForeground:[UIColor blackColor] andIsLight:true];
}
Painter:
+ (void)paint:(UIViewController *)controller withBackground:(UIColor *)backgroundColor andForeground:(UIColor *)foregroundColor andIsLight:(bool)isLight
{
controller.navigationController.navigationBar.opaque = true;
controller.navigationController.navigationBar.translucent = false;
controller.navigationController.navigationBar.tintColor = foregroundColor;
controller.navigationController.navigationBar.barTintColor = backgroundColor;
controller.navigationController.navigationBar.backgroundColor = backgroundColor;
controller.navigationController.navigationBar.barStyle = isLight ? UIBarStyleDefault : UIBarStyleBlack;
controller.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: foregroundColor};
}
Это ошибка? Есть ли что-то, что я могу сделать, чтобы исправить это? Это очень расстраивает.