使 UINavigationBar 半透明
Posted
技术标签:
【中文标题】使 UINavigationBar 半透明【英文标题】:Make UINavigationBar translucent 【发布时间】:2011-11-08 15:19:06 【问题描述】:我正在制作幻灯片。我希望导航栏看起来与照片应用程序中的相同。我如何获得这种透明度?
我试过了:
- (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】:我相信您正在寻找UINavigationBar
的translucent
属性。试试:
[[self.navigationController navigationBar] setTranslucent:YES];
【讨论】:
以上是关于使 UINavigationBar 半透明的主要内容,如果未能解决你的问题,请参考以下文章