Get nice, dark UIToolbar blur as in Facebook iOS 7 app Get nice, dark UIToolbar blur as in Facebook iOS 7 app ios ios

Get nice, dark UIToolbar blur as in Facebook iOS 7 app


Apparently the trick here is to insert the translucent layer as a sublayer of the navigation bar. I take no credit for finding this, and the following snippet has been taken from this gist.

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


I couldn't get the desired results unless I have added the following lines to the answer above:

 [self.navigationBar setBackgroundImage:[UIImage new]                             forBarMetrics:UIBarMetricsDefault];    self.navigationBar.shadowImage = [UIImage new];    self.navigationBar.translucent = YES;

Here is the full code

[self.navigationBar setBackgroundImage:[UIImage new]                         forBarMetrics:UIBarMetricsDefault];self.navigationBar.shadowImage = [UIImage new];self.navigationBar.translucent = YES;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];