Brief introduction
The colours– color library, which contains 100 predefined colors and methods, simplifies related development efforts.
Project home: Colours
Latest example: Click to download
Quick StartInstallationInstallation via Cocoapods
Pod ' Colours '
Manual Installation
Drag Colours.h and colours.m into your project and introduce the header files where you need them:
#import "Colours.h"
UsePalette, a set of pre-defined colors
Click here to view: 100 pre-defined colors
Use pre-defined colors
Colours has more than 100 colors pre-defined and is used in the same way that iOS systems are predefined:
[Uicolor Indigocolor]; Indigocolor is a pre-defined color of colours.
Color-dependent tool methodshexadecimal strings and colors convert to each other
Uicolor *newcolor = [Uicolor colorfromhexstring:@ "#f587e4"]; NSString *hexstring = [Newcolor hexstring];
Conversion of RGBA to color.Conversion between RGBA arrays and colors
Nsarray *colorarray = [[Uicolor Seafoamcolor] The rgbaarray];//array stores four NSNumber objects representing the four values of RGBA, with a range of 0-1. Uicolor *newcolor = [Uicolor Colorfromrgbaarray:colorarray];
Conversion between RGBA dictionaries and colors
The predefined four keys are:
kColoursRGBA_R
kColoursRGBA_G
kColoursRGBA_B
kColoursRGBA_A
Nsdictionary *colordict = [[Uicolor seafoamcolor] rgbadictionary]; Uicolor *newcolor = [Uicolor colorfromrgbadictionary:colordict]; You can get a single value: NSNumber *r = Colordict[kcoloursrgba_r];
HSBA Array and color conversion
Nsarray *colorarray = [[Uicolor Seafoamcolor] hsbaarray];//array stores four NSNumber, respectively representing H (Hue), S (color saturation), B (luminance), a (transparency) value. Nsdictionary *colordict = [[Uicolor seafoamcolor] hsbadictionary];
HSBA and color Conversion
Like Rgba and color conversion, the predefined keys are:
kColoursHSBA_H 色调
kColoursHSBA_S 色饱和度
kColoursHSBA_B 色亮度
kColoursHSBA_A 透明度
Nsarray *colorarray = [[Uicolor seafoamcolor] hsbaarray]; Nsdictionary *colordict = [[Uicolor seafoamcolor] hsbadictionary]; Uicolor *newcolor1 = [Uicolor Colorfromhsbaarray:colorarray]; Uicolor *newcolor2 = [Uicolor colorfromhsbadictionary:colordictionary];
CIELAB and color conversion
Like Rgba and color conversion, the predefined keys are:
kColoursCIE_L
kColoursCIE_A
kColoursCIE_B
kColoursCIE_alpha
Nsarray *colorarray = [[Uicolor seafoamcolor] cie_labarray]; Nsdictionary *colordict = [[Uicolor seafoamcolor] cie_labdictionary]; Uicolor *newcolor1 = [Uicolor Colorfromcie_labarray:colorarray]; Uicolor *newcolor2 = [Uicolor colorfromcie_labdictionary:colordictionary];
The conversion between CMYK and color
Similar to the conversion usages of RGBA and color, the predefined keys are:
kColoursCMYK_C 青
kColoursCMYK_M 品红
kColoursCMYK_Y 黄
kColoursCMYK_K 黑
Nsarray *colorarray = [[Uicolor seafoamcolor] cmykarray]; Nsdictionary *colordict = [[Uicolor seafoamcolor] cmykdictionary]; Uicolor *newcolor1 = [Uicolor Colorfromcmykarray:colorarray]; Uicolor *newcolor2 = [Uicolor colorfromcmykdictionary:colordictionary];
Get all color information
The Colorcomponents method returns a dictionary that contains all the predefined keys for Rgba, HSBA, Cie_lab, and CMYK:
Nsdictionary *components = [Somecolor colorcomponents]; CGFloat H = components[kcolourshsba_h]; CGFloat L = components[kcolourscie_l];
If you want only one color-related information at a time, you can use the following method:
CGFloat R = [[Uicolor tomatocolor] red]; CGFloat G = [[Uicolor tomatocolor] green]; CGFloat B = [[Uicolor tomatocolor] blue]; CGFloat H = [[Uicolor tomatocolor] hue]; CGFloat S = [[Uicolor tomatocolor] saturation]; CGFloat B = [[Uicolor tomatocolor] brightness]; CGFloat cie_l = [[Uicolor tomatocolor] cie_lightness]; CGFloat cie_a = [[Uicolor tomatocolor] cie_a]; CGFloat cie_b = [[Uicolor tomatocolor] cie_b]; CGFloat alpha = [[Uicolor Tomatocolor] alpha];
Color Lighten/Darken
Value range 0->1 Uicolor *lightercolor = [[Uicolor seafoamcolor] lighten:0.25f]; Uicolor *darkercolor = [[Uicolor seafoamcolor] darken:0.25f];
Get the contrast color
Depending on the given color, it can automatically form a contrasting color of black or white. Uicolor *contrastingcolor = [[Uicolor seafoamcolor] blackorwhitecontrastingcolor];
Get complementary colors
Returns the complementary color of a given color: tonal change, hue and saturation unchanged. Uicolor *complementary = [[Uicolor seafoamcolor] complementarycolor];
Get the difference between two colors
Here the difference, the comprehensive consideration of the human senses, mathematical statistics algorithm, etc., is not the general RGB difference. CGFloat distance = [Somecolor distancefromcolor:someothercolor type:colordistancecie94]; BOOL isnoticablysimilar = distance < threshold;
produce a variety of color schemes based on one color
Using the Colorschemeoftype method, you can create four new beautiful and appropriate colors based on one color, and return all five colors as an array. The same color, different schemes also produce different color combinations.
Nsarray *colorscheme = [color Colorschemeoftype:colorschemetype];
Optional color scheme:
colorschemeanalagous approximate color
Colorschememonochromatic Monochrome
Colorschemetriad Mixed color
Colorschemecomplementary Complementary color
The following is an example of the return value of a different color scheme based on the [Uicolor Seafoamcolor] Color:
Colorschemeanalagous
Colorschememonochromatic
Colorschemetriad
Colorschemecomplementary
colours– Color library with 100 predefined colors and methods