如何在UIView内部实现色轮?

时间:2011-02-18 15:01:57

标签: objective-c colors quartz-graphics

我搜索了网站,我发现了如何绘制色轮...... Math behind the Colour Wheel

但我想通过绘制UIView来实现它。但是如何使用Quartz技术呢?我应该用点或线画出来吗?谢谢

1 个答案:

答案 0 :(得分:0)

也许它适合你。

  1. CGContext ***用于绘制点或线,UIGraphicsGetImageFromCurrentImageContext用于获取UIImage项。
  2. - (void)drawPoint:(CGPoint)point {     CGContextBeginPath(UIGraphicsGetCurrentContext());     CGContextMoveToPoint(UIGraphicsGetCurrentContext(),point.x,point.y);     CGContextAddLineToPoint(UIGraphicsGetCurrentContext(),point.x,point.y);     CGContextStrokePath(UIGraphicsGetCurrentContext()); }

    - (void)drawLineFrom:(CGPoint)启动                   至:(CGPoint)结束{     CGContextBeginPath(UIGraphicsGetCurrentContext());     CGContextMoveToPoint(UIGraphicsGetCurrentContext(),start.x,start.y);     CGContextAddLineToPoint(UIGraphicsGetCurrentContext(),end.x,end.y);     CGContextStrokePath(UIGraphicsGetCurrentContext()); }

    1. 将UIImage绘制到UIView。 UIColor * backColor = [UIColor colorWithPatternImage:your_image_from_cgcontext]; view.backgroundColor = backColor;