iOS 16进制颜色和UIcolor的转换

鲜于致远
2023-12-01

各种颜色之间的转换,会陆续更新,

实现了 16进制颜色(HEX)、RGBA、HSBA、UIColor之间的  相互转换

 

  

使用示例(加号方法,类名调用)

 1     //UIColor 转 RGB、HSB
 2     RGBAColor colora = [ColorConversion UIColorToRGBA:[UIColor redColor]];
 3     HSBAColor colorb = [ColorConversion UIColorToHSBA:[UIColor redColor]];
 4     //RGB和HSB互转
 5     RGBAColor colorc = [ColorConversion HSBTORGB:colorb];
 6     HSBAColor colord = [ColorConversion RGBTOHSB:colora];
 7     //16进制数字、字串转UIColor
 8     UIColor * colore = [ColorConversion HEXNumTOUIColor:0xAFC078 Alpha:1];
 9     UIColor * colorf = [ColorConversion HEXStrTOUIColor:@"#AFC078" Alpha:1];
10

点我下载

转载于:https://www.cnblogs.com/kongkaikai/p/5044962.html

 类似资料: