[英]IB Color Issues
I noticed that when setting a UIView background in Xcode 6, the colors are different. 我注意到在Xcode 6中设置UIView背景时,颜色是不同的。 I am setting the 1st view with a Hex of #414042 in interface builder.
我在接口构建器中使用#414042的十六进制设置第一个视图。 And the second view with
0x414042
in code with the following HEX TO RGB macro. 第二个视图中的代码为
0x414042
,带有以下HEX TO RGB宏。
#define RGB(hexValue) [UIColor colorWithRed:((float)((hexValue & 0xFF0000) >> 16))/255.0 green:((float)((hexValue & 0xFF00) >> 8))/255.0 blue:((float)(hexValue & 0xFF))/255.0 alpha:1.0]
and as you can see there is a difference. 如您所见,两者有所不同。
In IB there is a gear setting to change the RGB type, but after changing that and trying to set the RGB, it resets back to sRGB. 在IB中,有一个齿轮设置可以更改RGB类型,但是在更改并尝试设置RGB之后,它将重置为sRGB。
Anyone know a way around this so the hex colors in code will match the hex color in IB? 有人知道如何解决此问题,以便代码中的十六进制颜色将与IB中的十六进制颜色匹配吗?
Is your iOS version 10+ ? 您的iOS版本是10+吗? see this apple document , Apple changed default color space, so if you want to xib using the same color as code,on xib ,you need to choose
Device RGB
or sRGB
, it is different with Generic RGB
看到此Apple文档 ,Apple更改了默认颜色空间,因此,如果要使用与代码相同的颜色xib,请在xib上选择
Device RGB
或sRGB
,这与Generic RGB
不同
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.