绘制渐变矩形的一种方法
2015-09-05 03:25
375 查看
- (void)drawRect:(CGRect)rect { // Drawing code [super drawRect:rect]; //draw wings [[UIColor blackColor] set]; CGFloat tempYPlace = self.currentSelectionY; if (tempYPlace < 0.0) { tempYPlace = 0.0; } else if (tempYPlace >= self.frame.size.height) { tempYPlace = self.frame.size.height - 1.0; } CGRect temp = CGRectMake(0.0, tempYPlace, self.frame.size.width, 1.0); UIRectFill(temp); //draw central bar over it CGFloat cbxbegin = self.frame.size.width * 0.2; CGFloat cbwidth = self.frame.size.width * 0.6; for (int y = 0; y < self.frame.size.height; y++) { [[UIColor colorWithHue:(y/self.frame.size.height) saturation:1.0 brightness:1.0 alpha:1.0] set]; CGRect temp = CGRectMake(cbxbegin, y, cbwidth, 1.0); UIRectFill(temp); } }
如图所示:
相关文章推荐
- 令人苦恼的调试缓慢问题
- zkw费用流模板
- hdu 3667 Transportation【费用流 + 拆边】
- 《你必须知道的.NET》读书实践:一个基于OO的万能加载器的实现
- 双飞翼布局(圣杯布局)介绍-始于淘宝UED
- Java堆.栈和常量池 笔记
- 圣杯布局与双飞翼布局的实现思路
- 圣杯布局与双飞翼布局的实现思路
- CSS布局奇淫巧计之-强大的负边距
- UVA 11235-Frequent values-RMQ(st表)+游程编码
- 一个简单的线程池
- Tomcat源码阅读系列(七)Session管理机制
- iOS开发脚踏实地学习day02-图片查看器和TOM猫
- python 函数的调用 和执行 小知识
- Design Pattern Explained 读书笔记五——Bridge
- Android 通知栏Notification的整合 全面学习 (一个DEMO让你完全了解它)
- Android Studio 中快速提取方法
- Linux文件系统的创建及挂载
- 经典算法:计算两个日期之间的天数
- Android Studio之Gradle多渠道打包