UIColor
- 父類是NSObject
UIColor的常用方法
-
直接創(chuàng)建對(duì)應(yīng)的顏色
+ (UIColor *)blackColor; // 0.0 white + (UIColor *)darkGrayColor; // 0.333 white + (UIColor *)lightGrayColor; // 0.667 white + (UIColor *)whiteColor; // 1.0 white + (UIColor *)grayColor; // 0.5 white + (UIColor *)redColor; // 1.0, 0.0, 0.0 RGB + (UIColor *)greenColor; // 0.0, 1.0, 0.0 RGB + (UIColor *)blueColor; // 0.0, 0.0, 1.0 RGB + (UIColor *)cyanColor; // 0.0, 1.0, 1.0 RGB + (UIColor *)yellowColor; // 1.0, 1.0, 0.0 RGB + (UIColor *)magentaColor; // 1.0, 0.0, 1.0 RGB + (UIColor *)orangeColor; // 1.0, 0.5, 0.0 RGB + (UIColor *)purpleColor; // 0.5, 0.0, 0.5 RGB + (UIColor *)brownColor; // 0.6, 0.4, 0.2 RGB + (UIColor *)clearColor; // 透明色
-
設(shè)置顏色透明度,透明度為0->1
[UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.2];// 三原色 [UIColor colorWithWhite:1.0 alpha:0.2]; [[UIColor whiteColor] colorWithAlphaComponent:0.2];
顏色相關(guān)的一些知識(shí)
- 顏色的基本組成
1. 一種顏色由N個(gè)顏色通道組成
- 顏色通道
1. 1個(gè)顏色通道占據(jù)8bit
2. 1個(gè)顏色通道的取值范圍
1. 10進(jìn)制 : [0, 255]
2. 16進(jìn)制 : [00, ff];
3. 常見的顏色通道
1. 紅色 red R
2. 綠色 green G
3. 藍(lán)色 blue B
4. 透明度 alpha A
4. R\G\B一樣的是灰色 - 顏色的種類
- 24bit顏色
1. 由R\G\B組成的顏色
2. 常見的表示形式
1. 10進(jìn)制(僅僅是用在CSS
)
1. 紅色 : rgb(255,0,0)
2. 綠色 : rgb(0,255,0)
3. 藍(lán)色 : rgb(0,0,255)
4. 黃色 : rgb(255,255,0)
5. 黑色 : rgb(0,0,0)
6. 白色 : rgb(255,255,255)
7. 灰色 : rgb(80,80,80)
2. 16進(jìn)制(可以用在CSS\android
)
1. 紅色 : #ff0000 #f00
2. 綠色 : #00ff00 #0f0
3. 藍(lán)色 : #0000ff #00f
4. 黃色 : #ffff00 #ff0
5. 黑色 : #000000 #000
6. 白色 : #ffffff #fff
7. 灰色 : #979797
- 32bit顏色
1. 由R\G\B\A組成的顏色
2. 常見的表示形式
1. 10進(jìn)制(僅僅是用在CSS
)
1. 紅色 : rgba(255,0,0,255)
2. 綠色 : rgba(0,255,0,255)
3. 藍(lán)色 : rgba(0,0,255,255)
4. 黃色 : rgba(255,255,0,255)
5. 黑色 : rgba(0,0,0,255)
6. 白色 : rgba(255,255,255,255)
2. 16進(jìn)制(#AARRGGBB, 僅僅是用在android)
1. 紅色 : #ffff0000
2. 綠色 : #ff00ff00
3. 藍(lán)色 : #ff0000ff
4. 黃色 : #ffffff00
5. 黑色 : #ff000000
6. 白色 : #ffffffff
- 24bit顏色