- CSDN da Rui elder brother
- Address: Http://blog.csdn.net/prevention
-
What are the built-in colors?
// Some convenience methods to create colors. These colors will be as calibrated as possible.// These colors are cached.+ (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;
How do you use them? Very simple:
UIColor *color = [UIColor redColor];
As a designer, can you specify RGB?
Of course:
+ (UIColor *)colorWithRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha;
This is also very easy to understand, the attention is red and green yellow and transparency, are in the range of 0 to 1.
As a professional designer, can you specify HSB?
Of course:
+ (UIColor *)colorWithHue:(CGFloat)hue saturation:(CGFloat)saturation brightness:(CGFloat)brightness alpha:(CGFloat)alpha;
The meaning should be more clear:
- Hue Hue
- Saturation of saturation
- Brightness brightness
Use pictures to make colors?
Actually still use the picture ... Many people are prone to ambiguity when it comes to understanding the function name.
+ (UIColor *)colorWithPatternImage:(UIImage *)image;
Application Scenarios:
UIImage *bgImage = [UIImageimageWithContentsOfFile:@"...\background.png"];UIColor *bgColor = [UIColor colorWithPatternImage:bgImage];self.backgroundColor =bgColor;
Gets a color after the current color changes transparency
The method signature is:
colorWithAlphaComponent
Application Scenarios:
UIColor *color = [UIColor redColor];UIColor *cl = [color colorWithAlphaComponent:0.5f];
-
Reprint please specify from: http://blog.csdn.net/prevention