Skip to content

A beautiful set of predefined colors and a set of color methods to make your iOS/OSX development life easier.

License

Notifications You must be signed in to change notification settings

teamtomsk/Colours

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ScreenShot

Build Status

Installation

Drag the included Colours.h and 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 "Colours.h" into the classes you want to use this category in and you're all set.

Cocoapods

pod 'Colours'

NSColor

Colours supports NSColor out of the box! Just make sure you have the AppKit framework installed (it comes that way for a new application) and you will be set. This README uses UIColor for its examples, just substitute NSColor and the methods are all the same.

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 a complementary color

This method will create a UIColor instance that is the exact opposite color from another UIColor on the color wheel. The same saturation and brightness are preserved, just the hue is changed.

UIColor *complementary = [[UIColor seafoamColor] complementaryColor];

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 beautiful set of predefined colors and a set of color methods to make your iOS/OSX development life easier.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 99.2%
  • Ruby 0.8%