博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
iOS 通过HEX(十六进制)得到一个UIColor的对象
阅读量:4657 次
发布时间:2019-06-09

本文共 710 字,大约阅读时间需要 2 分钟。

inline static UIColor* getColorFromHex(NSString *hexColor){        if (hexColor == nil) {        return nil;    }        unsigned int red, green, blue;    NSRange range;    range.length = 2;        range.location = 1;     [[NSScanner scannerWithString:[hexColor substringWithRange:range]] scanHexInt:&red];    range.location = 3;     [[NSScanner scannerWithString:[hexColor substringWithRange:range]] scanHexInt:&green];    range.location = 5;     [[NSScanner scannerWithString:[hexColor substringWithRange:range]] scanHexInt:&blue];	        return [UIColor colorWithRed:(float)(red/255.0f) green:(float)(green/255.0f) blue:(float)(blue/255.0f) alpha:1.0f];}

转载于:https://www.cnblogs.com/bhlsheji/p/5087963.html

你可能感兴趣的文章
Flex布局
查看>>
Java生鲜电商平台-异常模块的设计与架构
查看>>
Android中BroadcastReceiver广播
查看>>
使用SqlServer中的float类型时发现的问题(转)
查看>>
JS判断图片是否加载完成 背景图404 快到碗里来
查看>>
Programming Python - 2. System Tools -2.5 Parallel System Tools
查看>>
kvm虚拟机创建和管理(2)
查看>>
python学习的第一个星期
查看>>
Codeforces Round #277 (Div. 2) LIS of Sequence Dp
查看>>
替换字符串
查看>>
Git提交代码报错Git push error:src refspec XXX matches more than one解决方案
查看>>
PBOC电子现金的交易流程
查看>>
XML属性
查看>>
Color Sort
查看>>
mysql常用命令
查看>>
Git版本控制:Github的使用之 多人协作及参与项目
查看>>
【Maven】Missing artifact com.sun:tools:jar:1.5.0
查看>>
【转载】缓存框架
查看>>
python的迭代器
查看>>
spy memcached spring demo
查看>>