iOS-色彩UIColor
来源:互联网 发布:python中文编码问题 编辑:程序博客网 时间:2024/05/01 17:50
UIColor这个类提供了许多不同的方法,可以很轻松地调出任何颜色。你可以用静态方法来创建 颜色,这样它们会在停止使用后被释放。可以用灰度值、色相或者RGB复合值等多种形式来创建颜色。要创建一个简单的RGB色彩,可以指定一组4个浮点值, 分别对应红、绿、蓝和alpha值(透明度),取值均在0.0~1.0之间。这些值表示了0%
(0.0)~100%(1.0)的范围:
UIColor *myWhiteTransparentColor = [ UIColor colorWithWhite: 1.0 alpha: 0.50 ]; UIColor *myColorHue = [ UIColor colorWithHue: 120.0 / 360.0 saturation: 0.75 brightness: 0.50 alpha: 1.0 ]; UIColor *myColorRGB = [ UIColor colorWithRed: 0.75 green: 1.0 blue: 0.75 alpha: 1.0 ];
如果你打算重用许多不同的UIColor对象,你也可以创建它们的实例:
UIColor *myWhiteTransparentColor = [ [ UIColor alloc ] initWithWhite: 1.0 alpha: 0.50 ]; UIColor *myColorHue = [ [ UIColor alloc ] initWithHue: 120.0 / 360.0 saturation: 0.75 brightness: 0.50 alpha: 1.0 ]; UIColor *myColorRGB = [ [ UIColor alloc ] initWithRed: 0.75 green: 1.0 blue: 0.75 alpha: 1.0 ];
UIColor类还支持许多静态方法,可以创建系统颜色,这些颜色都经过iPhone的校正,以达到尽可能准确的地步。这些方法如下所示,均来自UIColor.h:
+ (UIColor *)blackColor; // 0.0 白色 + (UIColor *)darkGrayColor; // 0.333 白色 + (UIColor *)lightGrayColor; // 0.667 白色 + (UIColor *)whiteColor; // 1.0 白色 + (UIColor *)grayColor; // 0.5 白色 + (UIColor *)redColor; // 1.0, 0.0, 0.0 RGB + (UIColor *)greenColor; // 0.0, 1.0, 0.0 RGB + (UIColor *)blueColor; // 0.0, 0.0, 1.0 RGB + (UIColor *)cyanColor; // 0.0, 1.0, 1.0 RGB + (UIColor *)yellowColor; // 1.0, 1.0, 0.0 RGB + (UIColor *)magentaColor; // 1.0, 0.0, 1.0 RGB + (UIColor *)orangeColor; // 1.0, 0.5, 0.0 RGB + (UIColor *)purpleColor; // 0.5, 0.0, 0.5 RGB + (UIColor *)brownColor; // 0.6, 0.4, 0.2 RGB + (UIColor *)clearColor; // 0.0 白色, 0.0 alpha
创建好UIColor对象之后,就可以将其赋给文本视图的色彩属性了:
textView.textColor = myColorHue;
- iOS-色彩UIColor
- IOS-文字色彩UIColor
- IOS-文字色彩UIColor
- [iOS][UIColor *] 常用色彩的RGB值
- iOS UIColor
- IOS UIcolor
- iOS uicolor
- ios uicolor设置
- iOS 16进制转UIColor
- IOS UIColor 自定义颜色
- IOS UIColor 自定义颜色
- iOS 16进制转UIColor
- IOS UIColor 自定义颜色
- iOS-UIImage 互转 UIColor
- IOS UIColor 自定义颜色
- ios UIColor 自定义颜色
- IOS UIColor 自定义颜色
- iOS:16进制转UIColor
- 日志操作实现思路
- C#用什么方法可以减少或不使用switch
- PKU ACM/ICPC竞赛队最近八年比赛成绩
- Android实现电话状态监控
- C++异常机制的实现方式和开销分析
- iOS-色彩UIColor
- BOJ 319 3230391's easy problem
- android之layout_weight详解
- C#Winform获取屏幕大小
- 栈实现中缀表达式转为后缀表达式
- JNI学习系列(一)
- 利用Spring的AbstractRoutingDataSource解决多数据源的问题
- 关于vs未处理的异常: 0xC00000FD: Stack overflow
- java之插入排序