【问题标题】:Make UINavigationBar translucent使 UINavigationBar 半透明
【发布时间】: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)];

【问题讨论】:

    标签: iphone ios cocoa-touch uinavigationbar


    【解决方案1】:

    我相信您正在寻找UINavigationBartranslucent 属性。试试:

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

    【讨论】:

      猜你喜欢
      • 2014-11-05
      • 2018-06-18
      • 2011-01-19
      • 1970-01-01
      • 1970-01-01
      • 2014-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多