//
|
// UIColor+ZJFAdditon.m
|
// ProBIM
|
//
|
// Created by zjf on 2017/12/25.
|
// Copyright © 2017年 ProBIM. All rights reserved.
|
//
|
|
#import "UIColor+ZJFAdditon.h"
|
|
@implementation UIColor (ZJFAdditon)
|
+ (instancetype)z_colorWithHex:(uint32_t)hex alpha:(CGFloat)alpha {
|
//hex = 0xA3 B2 FF
|
int red = (hex & 0xFF0000) >> 16;
|
int green = (hex & 0x00FF00) >> 8;
|
int blue = (hex & 0x0000FF);
|
return [UIColor z_colorWithR:red G:green B:blue alpha:alpha];
|
}
|
+ (instancetype)z_colorWithR:(int)red G:(int)green B:(int)blue alpha:(CGFloat)alpha {
|
return [UIColor colorWithRed:red / 255.0 green:green / 255.0 blue:blue / 255.0 alpha:alpha];
|
}
|
+ (instancetype)z_colorWithHex:(uint32_t)hex {
|
int red = (hex & 0xFF0000) >> 16;
|
int green = (hex & 0x00FF00) >> 8;
|
int blue = (hex & 0x0000FF);
|
return [UIColor z_colorWithR:red G:green B:blue alpha:1.0];
|
}
|
+ (instancetype)z_colorWithR:(int)red G:(int)green B:(int)blue {
|
return [UIColor colorWithRed:red / 255.0 green:green / 255.0 blue:blue / 255.0 alpha:1.0];
|
}
|
+ (instancetype)z_randomColor {
|
return [UIColor z_colorWithR:arc4random_uniform(256) G:arc4random_uniform(256) B:arc4random_uniform(256) alpha:1];
|
}
|
@end
|