标签:监听 isp graphics path void uicolor current tom ack
// 监听slider滑动 - (IBAction)valueChnage:(UISlider *)sender; @property (weak, nonatomic) IBOutlet NJView *circleView; @end @implementation NJViewController - (IBAction)valueChnage:(UISlider *)sender { // NSLog(@"%.1f", sender.value); // 1.传递改变后的值给自定义view self.circleView.radius = sender.value; // 2.通知自定义view重新绘制图形 // [self.circleView setNeedsDisplay]; }
- (void)setRadius:(float)radius { _radius = radius; // 2.通知自定义view重新绘制图形 [self setNeedsDisplay]; } - (void)awakeFromNib { self.radius = 10; } - (void)drawRect:(CGRect)rect { // 1.获取上下文 CGContextRef ctx = UIGraphicsGetCurrentContext(); // 2.绘图 // CGContextAddEllipseInRect(ctx, CGRectMake(0, 0, 200, 200)); CGContextAddArc(ctx, 100, 100, self.radius, 0, 2 * M_PI, 0); [[UIColor purpleColor] set]; // 3.渲染 CGContextFillPath(ctx); }
标签:监听 isp graphics path void uicolor current tom ack
原文地址:http://www.cnblogs.com/liuwj/p/6597016.html