使UINavigationBar半透明

时间:2011-11-08 15:19:07

标签: iphone ios cocoa-touch uinavigationbar

我正在制作幻灯片。我希望导航栏看起来与照片应用程序中的相同。我如何获得这种透明度?

我试过了:

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

1 个答案:

答案 0 :(得分:2)

我相信您正在寻找translucent的{​​{1}}属性。尝试:

UINavigationBar
相关问题