iOS Development--color settings

Source: Internet
Author: User

Color settings:


Specify RGB, the number of parameters is red, green, yellow, transparency, the range is 0-1

+ (Uicolor *) colorwithred: (cgfloat) Red Green: (cgfloat) Green Blue: (cgfloat) Blue Alpha: (cgfloat) Alpha;

Specify HSB, number of parameters: Hue (hue), saturated (saturation), brightness (brightness)

+ (Uicolor *) Colorwithhue: (cgfloat) Hue saturation: (cgfloat) saturation brightness: (cgfloat) Brightness alpha: (CGFloat ) Alpha;

The color after which the current color changes transparency:

Uicolor *color = [Uicolor Redcolor]; Uicolor *CL = [color colorwithalphacomponent:0.5f];


Define a color value of 255 and turn 255 to 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;


Finally attached

Uicolor Official API Documentation:

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 Development--color settings

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.