iOS 通过HEX(十六进制)得到一个UIColor的对象
2014-05-07 08:51
393 查看
{
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];
}
相关文章推荐
- 【我所认知的BIOS】—> uEFI AHCI Driver(6) AtaAtapiPassThruSupported的局部变量们
- SQL 在OPENQUERY中使用参数
- Coded UI Test中的数据驱动测试
- 五、UI系统:layout
- Activity调用静态方法改变UI,使用Handler来改变UI显示
- QQ_UI之分类菜单DEMO(listView内嵌GridView
- SPOJ GSS3 Can you answer these queries III (线段树)
- 1Z0-051 QUESTION 4 单行函数Single-Row Functions
- 修改easyui panel 默认样式
- easyui 扩展tree 获取选中节点的级数
- easy UI获取数据,打开毕弹窗
- 1Z0-051 QUESTION 3 转译字符\在where语句中的使用
- 1Z0-051 QUESTION 2 选项WITH CHECK OPTION在CREATE VIEW中的使用
- UI线程
- 29.UICollectionView初步学习
- Pat(Advanced Level)Practice--1062(Talent and Virtue)
- 免费的swing/swt可视化开发工具windowbuilder
- Stirng,Stringbuffer,Stringbuild的区别浅淡
- Android自定义TabActivity(实现仿新浪微博底部菜单更新UI)
- 1Z0-051 QUESTION 1 利用CREATE TABLE AS创建表