当前位置:网站首页>Color is converted to tristimulus value (r/g/b) (dry stock)
Color is converted to tristimulus value (r/g/b) (dry stock)
2022-07-06 19:50:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm the king of the whole stack .
// Color conversion ##665522 — Trichromatic value + ( UIColor *)setFontColorWithString:( NSString *)color { NSString *cString = [[color stringByTrimmingCharactersInSet :[ NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString]; // The number of strings must be greater than or equal to 6 if ([cString length] < 6) { return [UIColorclearColor]; } // basis 16 Base to distinguish if ([cString hasPrefix:@”0X”]) cString = [cString substringFromIndex:2]; if ([cString hasPrefix:@”#”]) cString = [cString substringFromIndex:1]; if ([cString length] != 6) return [UIColorclearColor]; // It is divided into r,g,b Substring 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]; // scanning r,g,b value unsignedint r, g, b; [[NSScannerscannerWithString:rString] scanHexInt:&r]; [[NSScannerscannerWithString:gString] scanHexInt:&g]; [[NSScannerscannerWithString:bString] scanHexInt:&b]; return RgbHex2UIColor(r, g, b);
}
Copyright notice : This article is an original blog article , Blog , Without consent , Shall not be reproduced .
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/117138.html Link to the original text :https://javaforall.cn
边栏推荐
- JDBC details
- 算法面试经典100题,Android程序员最新职业规划
- Lick the dog until the last one has nothing (simple DP)
- Interview assault 63: how to remove duplication in MySQL?
- leetcode先刷_Maximum Subarray
- In simple terms, interview surprise Edition
- 语音识别(ASR)论文优选:全球最大的中英混合开源数据TALCS: An Open-Source Mandarin-English Code-Switching Corpus and a Speech
- MySQL information Schema Learning (i) - - General table
- 121. 买卖股票的最佳时机
- 小微企业难做账?智能代账小工具快用起来
猜你喜欢
随机推荐
Unbalance balance (dynamic programming, DP)
青龙面板白屏一键修复
How to customize animation avatars? These six free online cartoon avatar generators are exciting at a glance!
激进技术派 vs 项目保守派的微服务架构之争
Simple application of VBA script in Excel
HDU 1026 search pruning problem within the labyrinth of Ignatius and the prince I
新一代垃圾回收器—ZGC
A5000 vGPU显示模式切换
(3) Web security | penetration testing | basic knowledge of network security construction, IIS website construction, EXE backdoor generation tool quasar, basic use of
[translation] Digital insider. Selection process of kubecon + cloudnativecon in Europe in 2022
JDBC details
精彩编码 【进制转换】
PHP与EXCEL PHPExcel
小微企业难做账?智能代账小工具快用起来
350. 两个数组的交集 II
PowerPivot——DAX(初识)
Low CPU load and high loadavg processing method
121. The best time to buy and sell stocks
Alibaba数据源Druid可视化监控配置
《数字经济全景白皮书》保险数字化篇 重磅发布