UIColor+Flat
is an Objective C category to override UIColor's standard colors with beautiful Flat UI ones.
All new colors are taken from FlatUIColors.com.
There are some other classes available that will already grab these Flat UI colors, however, they all use the actual name of the color. eg. [UIColor flatEmeraldColor]
. Which I have found to be difficult to remember, and also annoying to implement into a project already containing the standard UIColor
methods.
What makes this better...? You don’t have to do anything differently. Just add the files, and you are locked and loaded and ready to make stuff prettier!
To use, just import UIColor+Flat.m
and UIColor+Flat.h
into your project, and use UIColor
as you normally would.
self.view.backgroundColor = [UIColor redColor];
As well as overriding the stand UIColor methods. A few more colors such as darkRedColor
have been added. Here is a full list of the colors.
[UIColor blackColor];
[UIColor darkGrayColor];
[UIColor grayColor];
[UIColor lightGrayColor];
[UIColor whiteColor];
[UIColor yellowColor];
[UIColor darkYellowColor];
[UIColor orangeColor];
[UIColor darkOrangeColor];
[UIColor redColor];
[UIColor darkRedColor];
[UIColor purpleColor];
[UIColor darkPurpleColor];
[UIColor blueColor];
[UIColor darkBlueColor];
[UIColor turqoiseColor];
[UIColor darkTurqoiseColor];
[UIColor greenColor];
[UIColor darkGreenColor];
A few bonus methods exist in UIColor+Flat.
- (UIColor *)contrastingColor;
Will return either [UIColor blackColor]
or [UIColor whiteColor]
, depending on which color will contrast most. Great for finding the text color to use on a colored background. (What I used to color the text in the previous image). eg.
label.textColor = [label.backgroundColor contrastingColor]
or
label.textColor = label.backgroundColor.contrastingColor
+ (UIColor *)colorFromHex:(UInt32)hex;
Will return the color from a hex value, such as 0x2C3E50
.
+ (UIColor *)colorFromHexString:(NSString*)hexString;
Will return a color from a hex string, either @"#2C3E50"
or @"2C3E50"
.
UIColor+Flat
is released under the MIT license.