Dawid
Dawid

Reputation: 145

Make UINavigationBar translucent

I am making with a slideshow in it. I want the navigation bar to look the same as in the photo app. How do I get this transparency?

I have tried:

- (void)drawRect:(CGRect)rect {
    [[UIColor clearColor] set];
    CGContextFillRect(UIGraphicsGetCurrentContext(), rect);

}   

UIImage *bg = [UIImage imageNamed:@"navbar.png"];
UIImageView *background = [[UIImageView alloc] initWithImage:bg];
background.frame = self.navigationController.toolbar.bounds;
background.autoresizingMask = UIViewAutoresizingFlexibleWidth;
BOOL isIOS5 = [[[UIDevice currentDevice] systemVersion] intValue] >= 5;
self.navigationController.toolbar.backgroundColor = [UIColor clearColor];
[self.navigationController.toolbar insertSubview:background atIndex: (isIOS5 ? 1 : 0)];

Upvotes: 0

Views: 2955

Answers (1)

Stuart
Stuart

Reputation: 37053

I believe you are looking for the translucent property of UINavigationBar. Try:

[[self.navigationController navigationBar] setTranslucent:YES];

Upvotes: 2

Related Questions