当前位置:网站首页>颜色(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
边栏推荐
- Interpretation of Dagan paper
- Interview assault 63: how to remove duplication in MySQL?
- Reflection and illegalaccessexception exception during application
- 【翻译】供应链安全项目in-toto移至CNCF孵化器
- 【翻译】云原生观察能力微调查。普罗米修斯引领潮流,但要了解系统的健康状况仍有障碍...
- 保证接口数据安全的10种方案
- 深度剖析原理,看完这一篇就够了
- GCC [7] - compilation checks the declaration of functions, and link checks the definition bugs of functions
- Phoenix Architecture 2 - accessing remote services
- Unbalance balance (dynamic programming, DP)
猜你喜欢
冒烟测试怎么做
A full set of teaching materials, real questions of Android interview of 7 major manufacturers including Alibaba Kwai pinduoduo
Carte de réflexion + code source + notes + projet, saut d'octets + jd + 360 + tri des questions d'entrevue Netease
Interpretation of Dagan paper
面试突击63:MySQL 中如何去重?
PMP practice once a day | don't get lost in the exam -7.6
Understand yolov1 Part II non maximum suppression (NMS) in prediction stage
Spark foundation -scala
手把手教你学会js的原型与原型链,猴子都能看懂的教程
CCNP Part 11 BGP (III) (essence)
随机推荐
Using clip path to draw irregular graphics
黑马--Redis篇
Benefit a lot, Android interview questions
A method of removing text blur based on pixel repair
JDBC details
121. 买卖股票的最佳时机
学习探索-函数防抖
企业精益管理体系介绍
[pytorch] yolov5 train your own data set
【基础架构】Flink/Flink-CDC的部署和配置(MySQL / ES)
Leetcode 30. Concatenate substrings of all words
Druid database connection pool details
Is not a drawable (color or path): the vector graph downloaded externally cannot be called when it is put into mipmap, and the calling error program crashes
A full set of teaching materials, real questions of Android interview of 7 major manufacturers including Alibaba Kwai pinduoduo
MATLAB中deg2rad和rad2deg函数的使用
How to access localhost:8000 by mobile phone
1805. Number of different integers in the string
After solving 2961 user feedback, I made such a change
学习打卡web
激进技术派 vs 项目保守派的微服务架构之争