IOS开发之——颜色设置
Posted 振长策而御宇内
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了IOS开发之——颜色设置相关的知识,希望对你有一定的参考价值。
颜色设置:
指定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];
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
+
colorWithWhite:alpha: +
colorWithHue:saturation:brightness:alpha: +
colorWithRed:green:blue:alpha: +
colorWithCGColor: +
colorWithPatternImage: +
colorWithCIColor: –
colorWithAlphaComponent:
Initializing a UIColor Object
–
initWithWhite:alpha: –
initWithHue:saturation:brightness:alpha: –
initWithRed:green:blue:alpha: –
initWithCGColor: –
initWithPatternImage: –
initWithCIColor:
Creating a UIColor with Preset Component Values
+
blackColor +
darkGrayColor +
lightGrayColor +
whiteColor +
grayColor +
redColor +
greenColor +
blueColor +
cyanColor +
yellowColor +
magentaColor +
orangeColor +
purpleColor +
brownColor +
clearColor
以上是关于IOS开发之——颜色设置的主要内容,如果未能解决你的问题,请参考以下文章
iOS 4 中的 UINavigationBar 色调颜色闪烁