当前位置:网站首页>颜色(color)转换为三刺激值(r/g/b)(干股)
颜色(color)转换为三刺激值(r/g/b)(干股)
2022-07-06 11:47:00 【全栈程序员站长】
大家好,又见面了,我是全栈君。
// 颜色转换 ##665522 — 三色值 + ( UIColor *)setFontColorWithString:( NSString *)color { NSString *cString = [[color stringByTrimmingCharactersInSet :[ NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString]; // 字符串个数必须大于等于6 if ([cString length] < 6) { return [UIColorclearColor]; } // 依据16进制来区分 if ([cString hasPrefix:@”0X”]) cString = [cString substringFromIndex:2]; if ([cString hasPrefix:@”#”]) cString = [cString substringFromIndex:1]; if ([cString length] != 6) return [UIColorclearColor]; // 分为r,g,b 子字符串 NSRange range; range.location = 0; range.length = 2; //r NSString *rString = [cString substringWithRange:range]; //g range.location = 2; NSString *gString = [cString substringWithRange:range]; //b range.location = 4; NSString *bString = [cString substringWithRange:range]; // 扫描r,g,b值 unsignedint r, g, b; [[NSScannerscannerWithString:rString] scanHexInt:&r]; [[NSScannerscannerWithString:gString] scanHexInt:&g]; [[NSScannerscannerWithString:bString] scanHexInt:&b]; return RgbHex2UIColor(r, g, b);
}
版权声明:本文博客原创文章,博客,未经同意,不得转载。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/117138.html原文链接:https://javaforall.cn
边栏推荐
- In simple terms, interview surprise Edition
- [pytorch] yolov5 train your own data set
- Swiftui game source code Encyclopedia of Snake game based on geometryreader and preference
- After solving 2961 user feedback, I made such a change
- Druid 数据库连接池 详解
- Leetcode 30. Concatenate substrings of all words
- Teach you to learn JS prototype and prototype chain hand in hand, a tutorial that monkeys can understand
- Microservice architecture debate between radical technologists vs Project conservatives
- [translation] Digital insider. Selection process of kubecon + cloudnativecon in Europe in 2022
- LeetCode-1279. Traffic light intersection
猜你喜欢
Looting iii[post sequence traversal and backtracking + dynamic planning]
理解 YOLOV1 第二篇 预测阶段 非极大值抑制(NMS)
潇洒郎: AttributeError: partially initialized module ‘cv2‘ has no attribute ‘gapi_wip_gst_GStreamerPipe
深入浅出,面试突击版
凤凰架构3——事务处理
今日直播 | “人玑协同 未来已来”2022弘玑生态伙伴大会蓄势待发
The "white paper on the panorama of the digital economy" has been released with great emphasis on the digitalization of insurance
CPU负载很低,loadavg很高处理方法
[play with Linux] [docker] MySQL installation and configuration
如何自定义动漫头像?这6个免费精品在线卡通头像生成器,看一眼就怦然心动!
随机推荐
Lick the dog until the last one has nothing (simple DP)
USB host driver - UVC swap
测试用里hi
Low CPU load and high loadavg processing method
350. Intersection of two arrays II
[translation] linkerd's adoption rate in Europe and North America exceeded istio, with an increase of 118% in 2021.
Hudi vs Delta vs Iceberg
About image reading and processing, etc
零基础入门PolarDB-X:搭建高可用系统并联动数据大屏
Dom 操作
反射及在运用过程中出现的IllegalAccessException异常
How to access localhost:8000 by mobile phone
JDBC详解
【翻译】数字内幕。KubeCon + CloudNativeCon在2022年欧洲的选择过程
【翻译】云原生观察能力微调查。普罗米修斯引领潮流,但要了解系统的健康状况仍有障碍...
Use of map (the data of the list is assigned to the form, and the JSON comma separated display assignment)
Hudi vs Delta vs Iceberg
主从搭建报错:The slave I/O thread stops because master and slave have equal MySQL serv
如何自定义动漫头像?这6个免费精品在线卡通头像生成器,看一眼就怦然心动!
DOM operation