gpt4 book ai didi

ios - iOS 中的十六进制颜色不准确

转载 作者:可可西里 更新时间:2023-11-01 04:23:20 31 4
gpt4 key购买 nike

<分区>

我发现当您在 xib 中设置 View 的 backgroundColor 时,显示的颜色与您以编程方式设置 backgroundColor 时明显不同。

这是一个例子。

我在这个简单的演示中有两个 View 。我在xib中设置了上 View 的backgroundColor,像这样: enter image description here

十六进制颜色值为 0x1BA9BA。然后我使用相同的十六进制颜色值以编程方式设置下 View 的 backgroundColor。我使用以下代码:

NSInteger hexValue = 0x1ba9ba;
self.testView.backgroundColor = [UIColor colorWithRed:((float)((hexValue & 0xFF0000) >> 16)) / 255.0
green:((float)((hexValue & 0xFF00) >> 8)) / 255.0
blue:((float)(hexValue & 0xFF))/255.0
alpha:1.0];

结果如下:

enter image description here

如您所见,颜色有明显差异。我在这里缺少什么?

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com