开发者

How to implement the color wheel inside the UIView?

开发者 https://www.devze.com 2023-02-11 17:10 出处:网络
I searched the web site, and I found how to draw a color wheel... Math behind the Colour Wheel B开发者_如何学运维ut I would like to implement it by drawing on the UIView. But how can I do using the Q

I searched the web site, and I found how to draw a color wheel... Math behind the Colour Wheel

B开发者_如何学运维ut I would like to implement it by drawing on the UIView. But how can I do using the Quartz technology? I should draw from by dots or lines? Thank you


Maybe its use for you.

  1. CGContext*** functions to draw dots or lines, and UIGraphicsGetImageFromCurrentImageContext to get UIImage item.

-(void) drawPoint:(CGPoint)point { CGContextBeginPath(UIGraphicsGetCurrentContext()); CGContextMoveToPoint(UIGraphicsGetCurrentContext(), point.x, point.y); CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), point.x, point.y); CGContextStrokePath(UIGraphicsGetCurrentContext()); }

-(void) drawLineFrom:(CGPoint)start to:(CGPoint)end { CGContextBeginPath(UIGraphicsGetCurrentContext()); CGContextMoveToPoint(UIGraphicsGetCurrentContext(), start.x, start.y); CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), end.x, end.y); CGContextStrokePath(UIGraphicsGetCurrentContext()); }

  1. Draw UIImage to UIView. UIColor* backColor = [UIColor colorWithPatternImage:your_image_from_cgcontext]; view.backgroundColor = backColor;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号