Skip to content

A collection of predefined UIColors you can use in your apps. Just include the Colours.h/.m files and you'll have a slew of new colors to use.

License

Notifications You must be signed in to change notification settings

TheEngineerz/Colours-for-iOS

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ScreenShot

Installation

Drag the included UIColor+Colours.h and UIColor+Colours.m files into your project. They are located in the top-level directory. You can see a demo of how to use these with the included Xcode project as well.

#import "UIColor+Colours.h" into the classes you want to use this category in and you're all set.

Cocoapods

pod 'Colours', '~> 3.1'

Color Palette

infoBlueColorinfoBlueColorsuccessColorsuccessColorwarningColorwarningColor
dangerColordangerColorantiqueWhiteColorantiqueWhiteColoroldLaceColoroldLaceColor
ivoryColorivoryColorseashellColorseashellColorghostWhiteColorghostWhiteColor
snowColorsnowColorlinenColorlinenColorblack25PercentColorblack25PercentColor
black50PercentColorblack50PercentColorblack75PercentColorblack75PercentColorwarmGrayColorwarmGrayColor
coolGrayColorcoolGrayColorcharcoalColorcharcoalColortealColortealColor
steelBlueColorsteelBlueColorrobinEggColorrobinEggColorpastelBlueColorpastelBlueColor
turquoiseColorturquoiseColorskyBlueColorskyBlueColorindigoColorindigoColor
denimColordenimColorblueberryColorblueberryColorcornflowerColorcornflowerColor
babyBlueColorbabyBlueColormidnightBlueColormidnightBlueColorfadedBlueColorfadedBlueColor
icebergColoricebergColorwaveColorwaveColoremeraldColoremeraldColor
grassColorgrassColorpastelGreenColorpastelGreenColorseafoamColorseafoamColor
paleGreenColorpaleGreenColorcactusGreenColorcactusGreenColorchartreuseColorchartreuseColor
hollyGreenColorhollyGreenColoroliveColoroliveColoroliveDrabColoroliveDrabColor
moneyGreenColormoneyGreenColorhoneydewColorhoneydewColorlimeColorlimeColor
cardTableColorcardTableColorsalmonColorsalmonColorbrickRedColorbrickRedColor
easterPinkColoreasterPinkColorgrapefruitColorgrapefruitColorpinkColorpinkColor
indianRedColorindianRedColorstrawberryColorstrawberryColorcoralColorcoralColor
maroonColormaroonColorwatermelonColorwatermelonColortomatoColortomatoColor
pinkLipstickColorpinkLipstickColorpaleRoseColorpaleRoseColorcrimsonColorcrimsonColor
eggplantColoreggplantColorpastelPurpleColorpastelPurpleColorpalePurpleColorpalePurpleColor
coolPurpleColorcoolPurpleColorvioletColorvioletColorplumColorplumColor
lavenderColorlavenderColorraspberryColorraspberryColorfuschiaColorfuschiaColor
grapeColorgrapeColorperiwinkleColorperiwinkleColororchidColororchidColor
goldenrodColorgoldenrodColoryellowGreenColoryellowGreenColorbananaColorbananaColor
mustardColormustardColorbuttermilkColorbuttermilkColorgoldColorgoldColor
creamColorcreamColorlightCreamColorlightCreamColorwheatColorwheatColor
beigeColorbeigeColorpeachColorpeachColorburntOrangeColorburntOrangeColor
pastelOrangeColorpastelOrangeColorcantaloupeColorcantaloupeColorcarrotColorcarrotColor
mandarinColormandarinColorchiliPowderColorchiliPowderColorburntSiennaColorburntSiennaColor
chocolateColorchocolateColorcoffeeColorcoffeeColorcinnamonColorcinnamonColor
almondColoralmondColoreggshellColoreggshellColorsandColorsandColor
mudColormudColorsiennaColorsiennaColordustColordustColor

Using Predefined Colors

Colours was set up to be exactly like using an Apple predefined system color. For instance, to get a stark red, you type [UIColor redColor]. You don't get a lot of variation on this though without diving into the colorWithRed:green:blue:alpha: method and customizing the heck out of it. Well, I took the liberty of creating 100 colors to use in the same system color way that Apple uses with iOS. So instead of the redColor example earlier, just substitute one of the colors from the giant palette above, like so: [UIColor indigoColor].

Color Helper Methods

Beyond giving you a list of a ton of colors with no effort, this category also gives you some methods that allow different color manipulations and translations. Here's how you use these:

Hex String to and from a UIColor

UIColor *newColor = [UIColor colorFromHexString:@"#f587e4"];
NSString *hexString = [newColor hexString];

RGBA Array to and from a UIColor

The color -> array method creates an array of 4 NSNumbers representing the RGBA values of the color. These are not in the 0-255 range, but rather normalized in the 0-1 range. So if your R is 230, then it will be represented in the array as 0.902.

NSArray *colorArray = [[UIColor seafoamColor] rgbaArray];
UIColor *newColor = [UIColor colorFromRGBAArray:colorArray];

RGBA Dictionary to and from a UIColor

Similar to the array method above, this returns an NSDictionary that contains NSNumbers for the keys: @"r",@"g",@"b",@"a".

NSDictionary *colorDict = [[UIColor seafoamColor] rgbaDictionary];
UIColor *newColor = [UIColor colorFromRGBADictionary:colorDict];

HSBA Array & Dictionary to and from a UIColor

Like both of the RGBA methods above, you can also get the Hue, Saturation and Brightness values from a UIColor and create an array or dictionary out of them, or vice versa.

NSArray *colorArray = [[UIColor seafoamColor] hsbaArray];
NSDictionary *colorDict = [[UIColor seafoamColor] hsbaDictionary];

UIColor *newColor1 = [UIColor colorFromHSBAArray:colorArray];
UIColor *newColor2 = [UIColor colorFromHSBADictionary:colorDictionary];

Generating white or black that contrasts with a UIColor

A lot of times you may want to put text on top of a view that is a certain color, and you want to be sure that it will look good on top of it. With this method you will return either white or black, depending on the how well each of them contrast on top of it. Here's how you use this:

UIColor *contrastingColor = [[UIColor seafoamColor] blackOrWhiteContrastingColor];

Generating Color Schemes

You can create a 5-color scheme based off of a UIColor using the following method. It takes in a UIColor and one of the ColorSchemeTypes defined in Colours. It returns an NSArray of 4 new UIColor objects to create a pretty nice color scheme that complements the root color you passed in.

NSArray *colorScheme = [color colorSchemeOfType:ColorSchemeType];

ColorSchemeTypes

  • ColorSchemeAnalagous
  • ColorSchemeMonochromatic
  • ColorSchemeTriad
  • ColorSchemeComplementary

Here are the different examples starting with a color scheme based off of [UIColor seafoamColor].

ColorSchemeAnalagous

Analagous

ColorSchemeMonochromatic

Monochromatic

ColorSchemeTriad

Triad

ColorSchemeComplementary

Complementary

Reap What I Sow!

This project is distributed under the standard MIT License. Please use this and twist it in whatever fashion you wish - and recommend any cool changes to help the code.

About

A collection of predefined UIColors you can use in your apps. Just include the Colours.h/.m files and you'll have a slew of new colors to use.

Resources

License

Stars

Watchers

Forks

Packages

No packages published