MCUIColorUtils扩展了UIColor
以添加一些方便的方法。
#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
}
如果您正在使用CocoaPods
,那么这很简单。将以下内容添加到您的Podfile
中,并运行pod install
。
pod 'MCUIColorUtils', :git => 'https://github.com/mirego/MCUIColorUtils.git'
不要忘记在需要的地方导入#import "UIColor+MCUIColorsUtils.h"
。
MCUIColorUtils是© 2013 Mirego,并且可以在新BSD许可下自由分发。请参阅LICENSE.md
文件。
Mirego是一支充满激情的团队,他们相信工作是一个您可以创新和玩乐的地方。我们自豪地为iPhone、iPad、Android、BlackBerry、Windows Phone和Windows 8开发了移动应用程序。了解更多关于我们团队的信息,请访问life.mirego.com。