我偶然发现了很多次,从未找到解决方案。
UINavigationController 的 navigationBar 可以设置为黑色半透明,如:
self.navigationController.navigationBar.barStyle=UIBarStyleBlackTranslucent;
此外,在 UINavigationBar 中有一个半透明属性,文档说:
When YES, the navigation bar is drawn with partial opacity, regardless of the bar style. The amount of opacity is fixed and cannot be changed. It is permissible to set the value of this property when the navigation bar is being managed by a navigation controller object.
我试过
self.navigationcontroller.navigationBar.tintColor=[UIColor blueColor];
self.navigationcontroller.navigationBar.translucent=YES;
和一千种变化:首先设置半透明属性,在 AppDelegate 和 ViewController 中设置它,首先设置 barstyle。
结果总是一样的:没有透明度。 因此我的问题是:
是否真的可以将半透明 UINavigationBar 的颜色更改为不同于黑色的颜色 (最好在 UINavigationController 中)?
我希望有一个审查安全的解决方案。
谢谢,米
最佳答案
一旦你知道它,它就相当简单:
self.navigationController.navigationBar.tintColor = [UIColor blueColor];
self.navigationController.navigationBar.alpha = 0.7f;
self.navigationController.navigationBar.translucent = YES;
translucent
属性似乎只是确定主视图是否应该在导航栏下可见,并适本地调整 View 的大小。
关于uinavigationcontroller - 更改半透明黑色 UINavigationBar 的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6781466/