Skip to content

Instantly share code, notes, and snippets.

@alanzeino
Last active April 26, 2020 23:34
Show Gist options
  • Star 48 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save alanzeino/6619253 to your computer and use it in GitHub Desktop.
Save alanzeino/6619253 to your computer and use it in GitHub Desktop.
Combining a strong colour with a blurred and translucent UINavigationBar in iOS 7.
// cheers to @stroughtonsmith for helping out with this one
UIColor *barColour = [UIColor colorWithRed:0.13f green:0.14f blue:0.15f alpha:1.00f];
UIView *colourView = [[UIView alloc] initWithFrame:CGRectMake(0.f, -20.f, 320.f, 64.f)];
colourView.opaque = NO;
colourView.alpha = .7f;
colourView.backgroundColor = barColour;
self.navigationBar.barTintColor = barColour;
[self.navigationBar.layer insertSublayer:colourView.layer atIndex:1];
@ericallam
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment