码迷,mamicode.com
首页 > 移动开发 > 详细

IOS开发之——颜色设置

时间:2014-10-07 18:15:53      阅读:224      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   io   os   ar   sp   div   

颜色设置:


指定RGB,參数是:红、绿、黄、透明度,范围是0-1

+ (UIColor *)colorWithRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha;

指定HSB,參数是:色调(hue),饱和的(saturation),亮度(brightness)

+ (UIColor *)colorWithHue:(CGFloat)hue saturation:(CGFloat)saturation brightness:(CGFloat)brightness alpha:(CGFloat)alpha;

当前的颜色改变透明度后的颜色:

UIColor *color = [UIColor redColor];
UIColor *cl = [color colorWithAlphaComponent:0.5f];


自己定义255的颜色值,将255转成0-1

CGFloat R  = (CGFloat) 225/255.0;
CGFloat G = (CGFloat) 66/255.0;
CGFloat B = (CGFloat) 88/255.0;
CGFloat alpha = (CGFloat) 1.0;
    
UIColor *myColorRGB = [ UIColor colorWithRed: R  green: G  blue: B  alpha: alpha  ];
self.tableView.backgroundColor = myColorRGB;


最后附上

UIColor官方API文档:

Creating a UIColor Object from Component Values

Initializing a UIColor Object

Creating a UIColor with Preset Component Values


IOS开发之——颜色设置

标签:style   blog   http   color   io   os   ar   sp   div   

原文地址:http://www.cnblogs.com/lcchuguo/p/4009390.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!