我正在制作幻灯片。我希望导航栏看起来与照片应用程序中的一样。我如何获得这种透明度?
我试过:
- (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)];
最佳答案
我相信您正在寻找 UINavigationBar
的 translucent
属性。尝试:
[[self.navigationController navigationBar] setTranslucent:YES];
关于iphone - 使 UINavigationBar 半透明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8052701/