为什么我不能为 UINavigationBar 设置自定义色调?
我想更改导航栏上的颜色,并且文档指出不要尝试更改“alpha”值。那么,如果所有构造函数都提供 alpha 值,如何设置不是 SDK 定义值的颜色(例如,[UIColor redColor]、brownColor 等)?我尝试获取当前的 alpha 值,但这没有帮助。当我使用自定义颜色时,它会导致导航栏看起来像 X 射线(粗糙的白底黑字)。
[self.navigationController.navigationBar setTintColor: [UIColor brownColor]];
I want to change the color on the navigation bar and the documentation states not to attempt to change the 'alpha' value. So, how can I set a color that is not the SDK defined values (e.g., [UIColor redColor], brownColor, etc.) if all the constructors provide an alpha value? I tried getting the current alpha value but that did not help. When I use a custom color, it causes the navigation bar to look like an x-ray (a scraggy, black-on-white).
[self.navigationController.navigationBar setTintColor: [UIColor brownColor]];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我真是个白痴……几个月来,我假设值的范围是 0..255(即 HTML 颜色值),但它们的范围是 [0.0 .. 1.0]。现在我设置了 0..255 值并将其标准化为 0..1,它按预期工作。我编写了一个简单的颜色滑块应用程序,当我调试它时,我意识到了我的错误。
I can be such an idiot ... for months now, I assumed the values ranged from 0..255 (i.e., HTML color values), but they are in the range [0.0 .. 1.0]. Now that I set my 0..255 value and normalize it to 0..1 it works as expected. I wrote a simple color-slider application and when I was debugging it, is when I realized my mistake.
试试这个:
最初创建 UINavigationController 时
Try this:
When creating the UINavigationController initially