获取RGB颜色并使用UIColor在iPhone上进行标准化 [英] Taking an RGB color and normalizing it with UIColor on the iPhone

查看:106
本文介绍了获取RGB颜色并使用UIColor在iPhone上进行标准化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种直接的方式来转换一种颜色从RGB,抓住它从一个工具,如Photoshop,然后将其转换为UIColor。由于UIColor对每个颜色空间使用了0.0到1.0的标准化色域,因此我不知道这是如何完成的。

I'm looking for a straight forward way to convert a color from RGB, grabbing it from a tool like Photoshop, then convert it to a UIColor. Since UIColor uses normalized gamut of 0.0 to 1.0 for each color space, I'm not sure how this is done.

感谢您的解决方案。

推荐答案

您的值介于0到255之间。使用它们创建UIColor:

Your values are between 0 and 255. Use them to create a UIColor:

float r; float g; float b; float a;

[UIColor colorWithRed:r/255.f
                green:g/255.f
                 blue:b/255.f    
                alpha:a/255.f];

这篇关于获取RGB颜色并使用UIColor在iPhone上进行标准化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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