2011-11-08 276 views
0

我制作幻灯片放映。我希望导航栏看起来与照片应用程序中的相同。我如何获得这种透明度?使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)]; 

回答

2

我相信你正在寻找UINavigationBartranslucent财产。试试:

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