xcode ios 半透明导航栏但导航栏按钮坚固

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11462978/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 00:52:45  来源:igfitidea点击:

ios translucent navigation bar but solid navigation bar buttons

iosxcodeuinavigationbaruibarbuttonitem

提问by user1467188

I'm trying to create this effect Fullscreen UIView with Status bar and Navigation Bar overlay on the top

我正在尝试创建这种效果 Fullscreen UIView,顶部有状态栏和导航栏覆盖

where the navigation bar is translucent, but the navigation bar buttons are solid.

导航栏是半透明的,但导航栏按钮是实心的。

self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
self.navigationController.navigationBar.alpha = .3;

This automatically makes the buttons translucent too. What's a workaround to make the buttons have a solid color?

这也会自动使按钮半透明。使按钮具有纯色的解决方法是什么?

Thanks!

谢谢!

回答by jhilgert00

Get id of your second line of code: self.navigationController.navigationBar.alpha = .3;and the navigation bar will be translucent and it will "appear" like the buttons are solid, but it's just a "translucent" button on top of a "translucent" bar, giving the illusion of a solid button.

获取第二行代码的 id:self.navigationController.navigationBar.alpha = .3;导航栏将是半透明的,它会像按钮一样“出现”,但它只是“半透明”栏顶部的“半透明”按钮,给人一种错觉实心按钮。

You won't be able to go lighter (.3) than the norm, unless you want to use images instead.

除非您想改用图像,否则您将无法比标准更轻 (.3)。