单军华
2018-07-19 83b9d5c682b21d88133f24da0f94dd56bd79e687
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
//
//  RRGB.m
//  RGB
//
//  Created by roycms on 2016/10/19.
//  Copyright © 2016年 roycms. All rights reserved.
//
 
#import "RRGB.h"
@implementation RRGB
 
+ (UIColor *)colorWithRGB16:(int)rgb {
    return [UIColor colorWithRed:((rgb & 0xFF0000) >> 16) / 255.0f
                           green:((rgb & 0xFF00) >> 8) / 255.0f
                            blue:((rgb & 0xFF)) / 255.0f
                           alpha:1.0f];
}
+ (UIColor *)colorWithRGBFromString:(NSString *)rgb {
    if ([rgb rangeOfString:@"#"].location != NSNotFound) {
        rgb = [rgb substringFromIndex:1];
    }
    rgb = [NSString stringWithFormat:@"0x%@",rgb];
    unsigned long rgb16 = strtoul([rgb UTF8String],0,16);
    
    return [self colorWithRGB16:(int)rgb16];
}
@end