UIColor+Categories 0.2

UIColor+Categories 0.2

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Dec 2014

Maintained by Unclaimed.


Downloads

Total471
Week0
Month0

Installs

Apps24
Test Targets1
powered by Segment

GitHub

Stars3
Watchers1
Forks0
Issues0
Contributors1
Pull Requests0

Code

Files4
LOCLines of Code 72


  • By
  • Matt Rubin

A collection of useful methods to extend the funtionality of UIColor.

UIColor+Integers

These replacement methods for the stock colorWith... constructors take integer parameters, like those commonly used in visual design software.

+ (instancetype)colorWithIntegerWhite:(NSUInteger)white;
+ (instancetype)colorWithIntegerWhite:(NSUInteger)white alpha:(NSUInteger)alpha;

+ (instancetype)colorWithIntegerRed:(NSUInteger)red green:(NSUInteger)green blue:(NSUInteger)blue;
+ (instancetype)colorWithIntegerRed:(NSUInteger)red green:(NSUInteger)green blue:(NSUInteger)blue alpha:(NSUInteger)alpha;

+ (instancetype)colorWithIntegerHue:(NSUInteger)hue saturation:(NSUInteger)saturation brightness:(NSUInteger)brightness;
+ (instancetype)colorWithIntegerHue:(NSUInteger)hue saturation:(NSUInteger)saturation brightness:(NSUInteger)brightness alpha:(NSUInteger)alpha;

UIColor+Macros

The COLOR macro simplifies the process of creating semantically-named shared static colors.

@interface UIColor (MyColors)

+ (instancetype)myFavoriteColor;
+ (instancetype)myLeastFavoriteColor;

@end

@implementation UIColor (MyColors)

// The hard way:
+ (instancetype)myFavoriteColor
{
    static UIColor *_myFavoriteColor;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _myFavoriteColor = [UIColor colorWithRed:0 green:0.75 blue:1 alpha:1];
    });
    return _myFavoriteColor;
}

// The easy way:
COLOR(myLeastFavoriteColor, [UIColor colorWithRed:0.55 green:0.6 blue:0.4 alpha:1])

@end

License

UIColor+Categories is available under the MIT License. See the LICENSE file for more info.