How to initialize UIColor from RGB values properly?

后端 未结 6 2323
春和景丽
春和景丽 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条回答
  •  甜味超标
    2020-12-23 19:34

    You got several options

    Code

    CGFloat red = 16.0;
    CGFloat green = 97.0;
    CGFloat blue = 5.0;
    CGFloat alpha = 255.0;
    UIColor *color = [UIColor colorWithRed:(red/255.0) green:(green/255.0) blue:(blue/255.0) alpha:(alpha/255.0)];
    

    Color picker plugin for Interface Builder

    There's a nice color picker from Panic which works well with IB: http://panic.com/~wade/picker/

    Xcode plugin

    This one gives you a GUI for choosing colors: http://www.youtube.com/watch?v=eblRfDQM0Go

    Pods and libraries

    There's a nice pod named MPColorTools: https://github.com/marzapower/MPColorTools

提交回复
热议问题