16进制颜色转UIColor
2015-10-09 13:57
344 查看
- (UIColor *)stringToColor:(NSString *)colorStr { unsigned int red,green,blue; NSRange range; range.length = 2; range.location = 0; [[NSScanner scannerWithString:[colorStr substringWithRange:range]]scanHexInt:&red]; range.location = 2; [[NSScanner scannerWithString:[colorStr substringWithRange:range]]scanHexInt:&green]; range.location = 4; [[NSScanner scannerWithString:[colorStr substringWithRange:range]]scanHexInt:&blue]; return [UIColor colorWithRed:(float)(red/255.0f)green:(float)(green / 255.0f) blue:(float)(blue / 255.0f)alpha:1.0f]; }
相关文章推荐
- iOS 编译失败,但是没有错误提示(ios build failed ,but without errors)
- Volley框架关于RequestQueue的心得
- 响应式web设计之CSS3 Media Queries
- 在非GUI程序中调用wxThread出现segmentation fault
- 不同情况下request.getContextPath()值的区别
- uitabBar上面的各定义选中时的图片颜色。不要渲染
- Arduino IDE的#ifdef bug
- 第二十九篇:使用SOUI的SMCListView控件
- [Android UI开发] viewpager fragment 切换时oncreateview调用多次问题
- iOS UILabel显示HTML文本
- 解决Django 提交表单时403错误:CSRF verification failed. Request
- UIView的layoutSubviews和drawRect方法何时调用
- 探究UIImagePickerController
- 循环队列_queue
- java中List、Map、Set、Collection、Stack、Queue等的使用
- Fourier Transform Intro - Oscillation frequency vs Angular frequency Expression
- poj 3498 March of the Penguins(最大流+拆点)
- Leetcode89: Unique Paths
- StringBuilder、StringBuffer和String三者的联系和区别
- UISegmentedControl的基本用法