-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUIColor+Helpers.m
36 lines (29 loc) · 1.17 KB
/
UIColor+Helpers.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//
// UIColor+Helpers.m
// WordPress
//
// Created by Danilo Ercoli on 07/06/12.
// Copyright (c) 2012 WordPress. All rights reserved.
//
#import "UIColor+Helpers.h"
@implementation UIColor (Helpers)
//[UIColor UIColorFromRGBAColorWithRed:10 green:20 blue:30 alpha:0.8]
+(UIColor *)UIColorFromRGBAColorWithRed: (CGFloat)r green:(CGFloat)g blue:(CGFloat)b alpha:(CGFloat)a {
return [UIColor colorWithRed: r/255.0 green: g/255.0 blue: b/255.0 alpha:a];
}
//[UIColor UIColorFromRGBColorWithRed:10 green:20 blue:30]
+(UIColor *)UIColorFromRGBColorWithRed:(CGFloat)r green:(CGFloat)g blue:(CGFloat)b {
return [UIColor colorWithRed: r/255.0 green: g/255.0 blue: b/255.0 alpha: 0.5];
}
//[UIColor UIColorFromHex:0xc5c5c5 alpha:0.8];
+(UIColor *)UIColorFromHex:(NSUInteger)rgb alpha:(CGFloat)alpha {
return [UIColor colorWithRed:((float)((rgb & 0xFF0000) >> 16))/255.0
green:((float)((rgb & 0xFF00) >> 8))/255.0
blue:((float)(rgb & 0xFF))/255.0
alpha:alpha];
}
//[UIColor UIColorFromHex:0xc5c5c5];
+(UIColor *)UIColorFromHex:(NSUInteger)rgb {
return [UIColor UIColorFromHex:rgb alpha:1.0];
}
@end