TestsTested | ✓ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Dec 2014 |
Maintained by Pixelslip.
Colorkit is a surcharge of UIColor class. It's bring you more methods to create and manipulate colors in your iOS projects.
To run the example project, clone the repo, and run pod install
from the Example directory first.
With Cocoapod
Colorkit is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "Colorkit"
With simple method
Drag and drop Colorkit.h and Colorkit.m files into your project. Don't forget to import the file into your project
#import "Colorkit.h"
+(instancetype)colorWithHexString:(NSString *)hexString
Create a color with a HEX String @"#FF0000", @"#F00", @"FF0000", @"F00"
UIColor *redColor = [UIColor colorWithHexString:@"#FF0000"];
UIColor *backgroundColor = [UIColor colorWithHexString:@"35A"];
+(instancetype)colorWithHexString:(NSString *)hexString alpha:(CGFloat)alpha
Same as above but with an alpha value (0-1)
UIColor *redColor = [UIColor colorWithHexString:@"#FF0000" alpha:0.5];
+(instancetype)colorWithRGB:(NSArray *)rgbArray
Create a color with an array of rgb values like @[@255,@120,@43]
UIColor *redColor = [UIColor colorWithRGB:@[@255, @0, @0]];
+(instancetype)colorWithRGBA:(NSArray *)rgbaArray
Create a color with an array of rgba values like @[@255,@120, @43, @0.5]
UIColor *redColor = [UIColor colorWithRGB:@[@255, @0, @0, @1]];
+(instancetype)colorWithHSB:(NSArray *)hsbArray
Create a color with an array of hsb values like @[@360,@80,@54]
UIColor *redColor = [UIColor colorWithHSB:@[@0, @100, @100]];
+(instancetype)colorWithHSBA:(NSArray *)hsbaArray
Create a color with an array of hsba values like @[@360,@80,@54,@0.5]
UIColor *redColor = [UIColor colorWithHSB:@[@0, @100, @100, @1]];
-(NSString *)getHexString
Get a HEX String from a Color
[redColor getHexString];
// @"#FF0000"
-(NSArray *)getRGBAArray
Get an Array of RGBA Numbers from a Color
[redColor getRGBAArray];
// @[@255, @0, @0, @1]
-(NSArray *)getHSBAArray
Get an Array of HSBA Numbers from a Color
[redColor getHSBAArray];
// @[@360, @100, @100, @1]
-(CGFloat)getRed
Get the red value of a Color
[redColor getRed];
// 255.0
-(CGFloat)getGreen
Get the green value of a Color
[redColor getGreen];
// 0.0
-(CGFloat)getBlue
Get the blue value of a Color
[redColor getBlue];
// 0.0
-(CGFloat)getHue
Get the hue value of a Color
[redColor getHue];
// 360.0
-(CGFloat)getSaturation
Get the saturation value of a Color
[redColor getSaturation];
// 100.0
-(CGFloat)getBrightness
Get the brightness value of a Color
[redColor getBrightness];
// 100.0
-(CGFloat)getAlpha
Get the alpha value of a Color
[redColor getAlpha];
// 1.0
-(instancetype)saturateColor:(CGFloat)amount
Saturate a color with a pourcentage value
[baseColor saturateColor:20.0];
-(instancetype)desaturateColor:(CGFloat)amount
Desaturate a color with a pourcentage value
[baseColor desaturateColor:20.0];
// == [baseColor saturateColor:-20.0];
-(instancetype)lightenColor:(CGFloat)amount
Light a color with a pourcentage value
[baseColor lightenColor:20.0];
-(instancetype)darkenColor:(CGFloat)amount
Saturate a color with a pourcentage value
[baseColor darkenColor:20.0];
-(instancetype)spinColor:(CGFloat)angle
Spin a color with a degre value
[baseColor spinColor:120.0];
-(instancetype)greyscaleColor
Return the color desaturate. Same as desaturateColor:100
[baseColor greyscaleColor];
+(instancetype)blendingColorsWithMultiply:(id)firstColor secondColor:(id)secondColor
Blending two colors with Multiply
[blendingColorsWithMultiply:[UIColor red] secondColor:[UIColor blue]];
+(instancetype)blendingColorsWithScreen:(id)firstColor secondColor:(id)secondColor
Blending two colors with Screen
[blendingColorsWithScreen:[UIColor red] secondColor:[UIColor blue]];
+(instancetype)blendingColorsWithOverlay:(id)firstColor secondColor:(id)secondColor
Blending two colors with Overlay
[blendingColorsWithOverlay:[UIColor red] secondColor:[UIColor blue]];
+(instancetype)blendingColorsWithSoftlight:(id)firstColor secondColor:(id)secondColor
Blending two colors with Softlight
[blendingColorsWithSoftlight:[UIColor red] secondColor:[UIColor blue]];
+(instancetype)blendingColorsWithHardlight:(id)firstColor secondColor:(id)secondColor
Blending two colors with Hardlight
[blendingColorsWithHardlight:[UIColor red] secondColor:[UIColor blue]];
+(instancetype)blendingColorsWithDifference:(id)firstColor secondColor:(id)secondColor
Blending two colors with Difference
[blendingColorsWithDifference:[UIColor red] secondColor:[UIColor blue]];
+(instancetype)blendingColorsWithExclusion:(id)firstColor secondColor:(id)secondColor
Blending two colors with Exclusion
[blendingColorsWithExclusion:[UIColor red] secondColor:[UIColor blue]];
pixelslip, [email protected]
Colorkit is available under the MIT license. See the LICENSE file for more info.