iOS 颜色空间

2023-12-23  本文已影响0人  Minoz_min

xib设置自定义颜色:颜色空间默认是Generic RGB

calibratedRGB.png
<color key="backgroundColor" red="0.8901960784313725" green="0.19215686274509802" blue="0.14117647058823529" alpha="1" colorSpace="calibratedRGB"/>

xib设置自定义颜色:颜色空间选择sRGB

sRGB.png
<color key="backgroundColor" red="0.8901960784313725" green="0.19215686274509802" blue="0.14117647058823529" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>

代码设置颜色:颜色空间默认是sRGB

view3.backgroundColor = UIColor(red: 227 / 255.0, green: 49 / 255.0, blue: 36 / 255.0, alpha: 1)

打印结果:

view 1: Optional(UIExtendedSRGBColorSpace 0.921313 0.283604 0.183076 1)
view 2: Optional(UIExtendedSRGBColorSpace 0.890196 0.192157 0.141176 1)
view 3: Optional(UIExtendedSRGBColorSpace 0.890196 0.192157 0.141176 1)
颜色对比图.png

通过ColorSet设置的颜色,颜色空间默认是sRGB(代码和xib中使用同一套颜色)

colorResource.png
<resources>
    <namedColor name="primary">
        <color red="0.8901960784313725" green="0.19215686274509805" blue="0.14117647058823529" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
    </namedColor>
</resources>
上一篇 下一篇

猜你喜欢

热点阅读