设置导航栏全透明的两种方法-Mark

1.设置一张透明的背景图片;

2.代码来写 如下:

- (void)setNavBackGround:(CGFloat)opacity

{

UIImage *transparentBackground;

UIGraphicsBeginImageContextWithOptions(CGSizeMake(1, 1), NO, self.navigationController.navigationBar.layer.contentsScale);

CGContextRef context = UIGraphicsGetCurrentContext();

CGContextSetRGBFillColor(context, 1, 142, 107, opacity);

UIRectFill(CGRectMake(0, 0, 1, 1));

transparentBackground = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

id navigationBarAppearance = self.navigationController.navigationBar;

[navigationBarAppearance setBackgroundImage:transparentBackground forBarMetrics:UIBarMetricsDefault];

}

你可能感兴趣的:(设置导航栏全透明的两种方法-Mark)