如何从UIColor获取RGB值? [英] How to get RGB values from UIColor?

查看:171
本文介绍了如何从UIColor获取RGB值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码创建一个颜色对象。

I'm creating a color object using the following code.

curView.backgroundColor = [[UIColor alloc] initWithHue:229 saturation:40 brightness:75 alpha:1];

如何从创建的颜色对象中检索RGB值?

How can I retrieve RGB values from the created color object?

推荐答案

const CGFloat *colors = CGColorGetComponents( curView.backgroundColor.CGColor );

这些链接提供了更多详细信息:

These links provide further details:

  • UIColor Reference
  • CGColorGetComponents reference

这篇关于如何从UIColor获取RGB值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆