Color and Color Spaces (颜色和颜色空间)

iOS supports the full range of color spaces available in Quartz; however, most apps should need only the RGB color space. Because iOS is designed to run on embedded hardware and display graphics onscreen, the RGB color space is the most appropriate one to use.

The UIColor object provides convenience methods for specifying color values using RGB, HSB, and grayscale values. When creating colors in this way, you never need to specify the color space. It is determined for you automatically by the UIColor object.

You can also use the CGContextSetRGBStrokeColor and CGContextSetRGBFillColor functions in the Core Graphics framework to create and set colors. Although the Core Graphics framework includes support for creating colors using other color spaces, and for creating custom color spaces, using those colors in your drawing code is not recommended. Your drawing code should always use RGB colors.

iOS支持Quartz提供的全系列色彩空间; 但是,大多数应用程序应该只需要RGB颜色空间。 由于iOS设计为在嵌入式硬件上运行并在屏幕上显示图形,因此RGB颜色空间是最合适的颜色空间。

UIColor对象提供了使用RGB,HSB和灰度值指定颜色值的便捷方法。 以这种方式创建颜色时,您永远不需要指定颜色空间。 它由UIColor对象自动确定。

您还可以使用Core Graphics框架中的CGContextSetRGBStrokeColorCGContextSetRGBFillColor函数来创建和设置颜色。 虽然Core Graphics框架包括支持使用其他颜色空间创建颜色,以及创建自定义颜色空间,但不建议在绘图代码中使用这些颜色。 您的绘图代码应始终使用RGB颜色。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值