iOS色彩空间——xib和代码设置颜色的偏差问题

通过Xib设置样式如下:

enter image description here


通过代码设置如下:

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

很明显,上面视图与下面视图是有色彩偏差的。

或许此时,你需要查看下xib设置中,你选择的色彩空间标准是sRGB 或 Device RGB,如下:



解决方式:选择Generic RGB,运行后,你会发现两个视图的色彩就是一样的了,效果如下:

enter image description here


参考:http://stackoverflow.com/questions/10039641/ios-color-on-xcode-simulator-is-different-from-the-color-on-device#new-answer


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值