透明导航栏,但保持iOS模糊
在iOS 7中,导航条对滚动到下方的内容具有模糊效果。我希望我的导航栏是透明的,其实现方式如下:透明导航栏,但保持iOS模糊,ios,objective-c,iphone,cocoa-touch,ios7,Ios,Objective C,Iphone,Cocoa Touch,Ios7,在iOS 7中,导航条对滚动到下方的内容具有模糊效果。我希望我的导航栏是透明的,其实现方式如下: [[UINavigationBar appearance] setBarStyle:UIBarStyleDefault]; [[UINavigationBar appearance] setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; [[UINavigationBar appearance] setShadowI
[[UINavigationBar appearance] setBarStyle:UIBarStyleDefault];
[[UINavigationBar appearance] setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setShadowImage:[UIImage new]];
[[UINavigationBar appearance] setBackgroundColor:[UIColor clearColor]];
但我希望内容也变得模糊。我尝试了以下方法,但没有成功:
[[UINavigationBar appearance] setBarTintColor:[UIColor clearColor]];
[[UINavigationBar appearance] setBarStyle:UIBarStyleDefault];
[[UINavigationBar appearance] setShadowImage:[UIImage new]];
[[UINavigationBar appearance] setBackgroundColor:[UIColor clearColor]];
相反,这会使导航栏模糊内容视图,但为黑色。如果删除SetPartInColor,导航栏会使内容模糊,但它是白色的。我尝试过各种其他组合,但导航栏不是白色就是黑色
我已经看了几个这样的问题,但它们对我没有帮助。他们回答了如何得到一个或,当我想要的是它是清晰/透明的,没有任何颜色的色调
我将如何实现这一点?谢谢你的帮助,非常感谢 使其半透明
将其子类化,并添加代码-
- (id)initWithRootViewController:(UIViewController *)rootViewController
{
if (self = [super initWithRootViewController:rootViewController]) {
self.navigationBar.translucent = YES;
}
return self;
}
尝试此操作,它基于工具栏的模糊透明度,您还可以为该工具栏添加一些颜色: 如果您需要iOS7支持,此解决方案很好
[self.navigationController.navigationBar setBackgroundImage:[UIImage new]
forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.shadowImage = [UIImage new];
self.navigationController.navigationBar.translucent = YES;
self.navigationController.view.backgroundColor = [UIColor clearColor];
UIToolbar* blurredView = [[UIToolbar alloc] initWithFrame:self.navigationController.navigationBar.bounds];
[blurredView setBarStyle:UIBarStyleBlack];
[self.navigationController.navigationBar insertSubview:blurredView atIndex:0];