How to initialize UIColor from RGB values properly?

后端 未结 6 2330
春和景丽
春和景丽 2020-12-23 18:47

I am working on an iPhone application which uses various colors. When user selects the particular color button I set drawing color accordingly. I am getting the color for so

6条回答
  •  猫巷女王i
    2020-12-23 19:45

    The values are in the 0.0 to 1.0 range.

    E.g. divide by 255., but remember the decimal dot so you get floating point division and not integer division.

    Like

    selectedColor = [UIColor colorWithRed:14.0/255.0 green:114.0/255.0 blue:199.0/255.0 alpha:1];
    

提交回复
热议问题