当前位置:网站首页>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
边栏推荐
- 爬虫(14) - Scrapy-Redis分布式爬虫(1) | 详解
- Web开发小妙招:巧用ThreadLocal规避层层传值
- AsyncHandler
- The slave i/o thread stops because master and slave have equal MySQL serv
- Example of applying fonts to flutter
- Chic Lang: attributeerror: partially initialized module 'CV2' has no attribute 'GAPI_ wip_ gst_ GStreamerPipe
- leetcode先刷_Maximum Subarray
- [translation] micro survey of cloud native observation ability. Prometheus leads the trend, but there are still obstacles to understanding the health of the system
- 部门树递归实现
- Mysql Information Schema 学习(一)--通用表
猜你喜欢

Interview assault 63: how to remove duplication in MySQL?

Mysql Information Schema 學習(一)--通用錶

Hudi vs Delta vs Iceberg

Zero foundation entry polardb-x: build a highly available system and link the big data screen

Blue Bridge Cup microbial proliferation C language

Teach you to learn JS prototype and prototype chain hand in hand, a tutorial that monkeys can understand

深度剖析原理,看完这一篇就够了
Classic 100 questions of algorithm interview, the latest career planning of Android programmers

Hudi vs Delta vs Iceberg

Li Kou 101: symmetric binary tree
随机推荐
Phoenix Architecture 3 - transaction processing
[calculating emotion and thought] floor sweeper, typist, information panic and Oppenheimer
学习探索-使用伪元素清除浮动元素造成的高度坍塌
2022年6月语音合成(TTS)和语音识别(ASR)论文月报
算法面试经典100题,Android程序员最新职业规划
Analysis of rainwater connection
DaGAN论文解读
Lick the dog until the last one has nothing (simple DP)
蓝桥杯 微生物增殖 C语言
Druid database connection pool details
Web开发小妙招:巧用ThreadLocal规避层层传值
121. 买卖股票的最佳时机
JDBC details
【翻译】供应链安全项目in-toto移至CNCF孵化器
Vmware虚拟机无法打开内核设备“\\.\Global\vmx86“的解决方法
部门树递归实现
MySQL must know and learn
short i =1; I=i+1 and short i=1; Difference of i+=1
Information System Project Manager - Chapter VIII project quality management
[infrastructure] deployment and configuration of Flink / Flink CDC (MySQL / es)