如何使导航栏均匀地半透明? [英] How can I make my navigation bar uniformly semi-transparent?
本文介绍了如何使导航栏均匀地半透明?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在iOS 7上编写一个应用程序,但似乎无法掌握NavigationBar和工具栏的透明度,如何将导航栏设置为不透明度为50%的黑色?
I'm writing an app on iOS 7, and I can't seem to get a handle on the transparency of the navigationBar and the toolbar, how can I set the navigation bar to black at 50% opacity?
我已经阅读了到ios7指南的过渡,并且观看了wwdc13讲座214,但是我的状态栏与其余的导航栏相比仍然具有不同的透明度.
I've read the transition to ios7 guide and I've watched the wwdc13 lecture 214, but my status bar still has a different transparency than the rest of the attached nav bar.
这是我的代码:
// APP-WIDE THEMING
[[UINavigationBar appearance] setBarStyle:UIBarStyleBlackOpaque];
[[UINavigationBar appearance] setBackgroundColor:[UIColor blueColor]];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
这是我的问题的屏幕截图: http://grab.by/qiyU
Here is the screenshot of my problem: http://grab.by/qiyU
推荐答案
将背景图片设置为nil,并使用alpha设置背景颜色.
Set the background image to nil, and set the background color with alpha.
[ctrl.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
ctrl.navigationController.navigationBar.backgroundColor = [UIColor colorWithRed:0 Green:0 Blue:0 Alpha:.5];
这篇关于如何使导航栏均匀地半透明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文