当前位置:网站首页>颜色(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
边栏推荐
- Carte de réflexion + code source + notes + projet, saut d'octets + jd + 360 + tri des questions d'entrevue Netease
- 面试突击63:MySQL 中如何去重?
- 零基础入门PolarDB-X:搭建高可用系统并联动数据大屏
- 【翻译】Linkerd在欧洲和北美的采用率超过了Istio,2021年增长118%。
- Druid database connection pool details
- MySQL information schema learning (I) -- general table
- Yyds dry goods inventory leetcode question set 751 - 760
- 潇洒郎: AttributeError: partially initialized module ‘cv2‘ has no attribute ‘gapi_wip_gst_GStreamerPipe
- 深入浅出,面试突击版
- 【翻译】云原生观察能力微调查。普罗米修斯引领潮流,但要了解系统的健康状况仍有障碍...
猜你喜欢

Analysis of rainwater connection

Hudi vs Delta vs Iceberg

Swiftui game source code Encyclopedia of Snake game based on geometryreader and preference

It's enough to read this article to analyze the principle in depth

Problems encountered in using RT thread component fish

DaGAN论文解读

信息系统项目管理师---第八章 项目质量管理

Understand yolov1 Part II non maximum suppression (NMS) in prediction stage

Computer network: sorting out common network interview questions (I)

手把手教你学会js的原型与原型链,猴子都能看懂的教程
随机推荐
C language daily practice - day 22: Zero foundation learning dynamic planning
Leetcode 30. 串联所有单词的子串
【翻译】数字内幕。KubeCon + CloudNativeCon在2022年欧洲的选择过程
手把手教你学会js的原型与原型链,猴子都能看懂的教程
思维导图+源代码+笔记+项目,字节跳动+京东+360+网易面试题整理
深入浅出,面试突击版
It's enough to read this article to analyze the principle in depth
通俗的讲解,带你入门协程
The slave i/o thread stops because master and slave have equal MySQL serv
CCNP Part 11 BGP (III) (essence)
[translation] supply chain security project in toto moved to CNCF incubator
思維導圖+源代碼+筆記+項目,字節跳動+京東+360+網易面試題整理
[play with Linux] [docker] MySQL installation and configuration
【翻译】Linkerd在欧洲和北美的采用率超过了Istio,2021年增长118%。
JDBC details
Fast power template for inverse element, the role of inverse element and example [the 20th summer competition of Shanghai University Programming League] permutation counting
Hudi vs Delta vs Iceberg
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
Systematic and detailed explanation of redis operation hash type data (with source code analysis and test results)
LeetCode_ Double pointer_ Medium_ 61. rotating linked list