iphone - 使 UINavigationBar 半透明

标签 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)];

最佳答案

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

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

关于iphone - 使 UINavigationBar 半透明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8052701/

相关文章:

iphone - 在 iPhone 网络应用程序中使用单选按钮的最佳方式是什么?

ios - iOS 中的延迟深度链接

iphone - App Store 提交错误 : A symbolic link resolves to a location outside of the binary

objective-c - iOS:加载 MKMapView 并添加注释/覆盖时的通知?

iphone - 过渡 UINavigationBar 颜色?

iphone - IOS - 如何在滚动元素时更新元素的界面?

iphone - 如何在表格中间初始化 UITableView

ios - dateFormatter 根据设备返回不同的日期

javascript - 从 JavaScript 函数调用 UIViewController

javascript - Cordova - 已弃用尝试访问非导航器对象上的属性 'userAgent'