-
-
Save alanzeino/6619253 to your computer and use it in GitHub Desktop.
I ended up doing three things to fix my transitioning issues.
-
I experienced an issue where the layer would actually block touches in the navigation bar when pushing another view controller on the stack. To fix this I set userInteractionEnabled to NO.
-
I tweaked the barTintColor property on my navigation bars and the backgroundColor of my nav view so the translucent bars on a plain content background look identical to my non translucent nav bars.
-
During navigation bar transitions, I remove the sublayer and set the navigation bar to non-translucent. Then once the transition finishes, I readd the sublayer and reenable transluceny.
It's not a perfect solution as you can slightly see changes in translucency if your colours aren't perfectly matched, but it's certainly better than before.
My navigation controller delegates look like this.
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
self.navigationBar.translucent = NO;
[self.navColourView.layer removeFromSuperlayer];
}
- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
self.navigationBar.translucent = YES;
[self.navigationBar.layer insertSublayer:self.navColourView.layer atIndex:1];
}
I've done the same thing above but my navigation delegate is a bit different. Instead of toggling the translucency it just moves the layer back into position on didShowViewController:
- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
[self.strongColorView.layer removeFromSuperlayer];
[navigationController.navigationBar.layer insertSublayer:self.strongColorView.layer atIndex:1];
}
While testing a storyboard-based master/detail I was able to get the effect to work through to the detail view by adding similar code to the viewDidLayoutSubviews event in the detail controller. But navigating back yields a strange bug where the title text becomes translucent while the rest is fine. Still working through this. So anyone with input please chime in.