Navigationbar coloring in ViewWillAppear happens too late in iOS 10 : <p>I am facing a weird bug, that happens only on iOS 10.</p>

<p>I have a application with several screens, and each screen colors the <code>navigationBar</code> in <code>viewWillAppear</code>. So when you go to the next screen, it will be properly colored.</p>

<p>However, when testing on iOS 10 I suddenly see the following behaviour when going back to a previous screen:
When the previous screen appears the <code>navigationBar</code> still has the color of the previous screen and then flashes to the proper color.
It almost looks like <code>viewWillAppear</code> somehow behaves as <code>viewDidAppear</code>.</p>

<p>Relevant code:</p>

<p>ViewController:</p>

<pre><code>- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [ViewControllerPainter paint:self withBackground:[UIColor whiteColor] andForeground:[UIColor blackColor] andIsLight:true];

}
</code></pre>

<p>Painter:</p>

<pre><code>+ (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};
}
</code></pre>

<p>Is this a bug? Is there something I can do about to fix this? It's very frustrating.</p>
