如何在类似于Apple照片应用程序中找到的UINavigationBar
上实现模糊?
当我使用这段代码时,我甚至看不到我的栏:
[self.navigationController.navigationBar setBackgroundImage:[UIImage new]
forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.shadowImage = [UIImage new];
self.navigationController.navigationBar.translucent = YES;
self.navigationController.view.backgroundColor = [UIColor whiteColor];
在AppDelegate.m中
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
答案 0 :(得分:0)
您要查找的行为称为translucency
,是UINavigationBar
的默认行为。您的应用程序默认情况下不会发生此行为吗?你都尝试了些什么?更多信息可以提供帮助。
Here's a link to the documentation for this property specifically.
编辑:我在SO上发现了一个类似的问题,如果你正在使用自定义背景图片,可以帮助你。 Find it here.
答案 1 :(得分:0)
制作半透明导航栏的最简单方法是不执行任何操作,因为这是默认设置。
你基本上阻止发生。让我们来看看你的代码:
酒吧的色调不是它的颜色。它是按钮和图像的颜色。如果您将色调颜色设置为白色并将背景颜色设置为白色,则表示您正在白色背景上创建白色按钮。那将是很难看到的!
另一方面,条形的颜色是barTintColor
。设置它,并将translucent
设置为YES。尝试各种barTintColor
值,看看会发生什么。
不设置背景颜色,因为这会使事情复杂化。
最重要的是, NOT 设置背景图像,尤其是不设置空图像,因为这会覆盖其他所有内容并在导航栏中打孔,使其完全透明。