Skip to content

mirego/MCUIColorUtils

Repository files navigation

MCUIColorUtils - UIColor missing methods.

Badge w/ Version Badge w/ Platform

MCUIColorUtils extends UIColor to add some convenience methods.

Using

#import "UIColor+MCUIColorsUtils.h"

- (void)funWithColors
{

  // Use colors straight from the web
  [UIColor colorForHex:@"#fafbfc"];

  // ... if you prefer you can go with bytes
  [UIColor colorWithHexRGB:0xfafbfc];
  [UIColor colorWithHexRGBA:0xfafbfcff];

  // ...or with 0-255 values
  [UIColor colorWithIntegerRed:250 green:251 blue:252];
  [UIColor colorWithIntegerRed:250 green:251 blue:252 alpha:255];

  // ...or if all the channels are the same
  [UIColor colorWithGray:0.980392157]; // 250/255=0.980392157
  [UIColor colorWithIntegerGray:250];  // #fafafa

  // Get a lighter color
  UIColor color* = [UIColor colorForHex:@"#123456"];
  [color colorWithMultiplier:1.10]; // 110% of rgb channels

  // ... or a darker color
  [color colorWithMultiplier:0.90]; // 90% of rgb channels
}

Adding to your project

If you're using CocoaPods, there's nothing simpler. Add the following to your Podfile and run pod install

pod 'MCUIColorUtils', :git => 'https://github.com/mirego/MCUIColorUtils.git'

Don't forget to #import "UIColor+MCUIColorsUtils.h" where it's needed.

License

MCUIColorUtils is © 2013-2015 Mirego and may be freely distributed under the New BSD license. See the LICENSE file.

About Mirego

Mirego is a team of passionate people who believe that work is a place where you can innovate and have fun. We're a team of talented people who imagine and build beautiful Web and mobile applications. We come together to share ideas and change the world.

We also love open-source software and we try to give back to the community as much as we can.