UIToolbar setBackgroundColor 没有完全改变颜色

2024-05-11

我正在尝试设置 a 的背景颜色UIToolBar。 我尝试从 IB 的属性检查器中选择颜色,并尝试通过编程方式设置它setBackgroundColor:[UIColor ...].

两种解决方案都有效,但只是部分有效:颜色与白色混合了大约 50%,并且工具栏非常浅......不显示我实际选择的颜色,而是显示它的浅得多的版本。

我怎样才能拥有UIToolBar我选择的实际颜色? 解决起来可能很简单,但是我找不到方法,网上也找不到答案。


在您的中写入以下代码viewDidLoad

self.navigationController.toolbar.barTintColor = [UIColor redColor];

它将设置红色作为您的工具栏背景。

Reference link https://web.archive.org/web/20160321155823/https://developer.apple.com/library/ios/documentation/userexperience/conceptual/TransitionGuide/Bars.html#//apple_ref/doc/uid/TP40013174- CH8-SW5 https://web.archive.org/web/20160321155823/https://developer.apple.com/library/ios/documentation/userexperience/conceptual/TransitionGuide/Bars.html#//apple_ref/doc/uid/TP40013174-CH8-SW5

In it they said that Use barTintColor to tint the bar background. enter image description here

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

UIToolbar setBackgroundColor 没有完全改变颜色 的相关文章

随机推荐