/**
* @brief UIColor转 #ffffff 格式的16进制字符串
*
* @return 格式为 #ff0000 的16进制字符串
*/
- (NSString *)hex_String {
const CGFloat *components = CGColorGetComponents(self.CGColor);
CGFloat r = components[0];
CGFloat g = components[1];
CGFloat b = components[2];
return [NSString stringWithFormat:@"#%02lX%02lX%02lX",lroundf(r * 255),lroundf(g * 255),lroundf(b * 255)];
}
标签:十六进制,lroundf,iOS,components,字符串,CGFloat,255
From: https://www.cnblogs.com/CH520/p/16966678.html