0

有什么方法可以退出drawRect:而不刷新当前UIView?例如:

- (void)drawRect:(CGRect)rect {

CGContextRef context = UIGraphicsGetCurrentContext();

CGContextSetRGBStrokeColor(context, 1.0, 1.0, 1.0, 1.0);
CGContextSetLineWidth(context, 2);

CGContextMoveToPoint(context, 10.0, 30.0);
CGContextAddLineToPoint(context, 310.0, 30.0);
CGContextStrokePath(context);


//I would like to return from here and rollback all changes in drawRect:

}

谢谢!

4

1 回答 1

0

如果您还没有开始绘制上下文,则可能只从drawRect:. 您必须clearsContextBeforeDrawing先将视图的属性设置为 NO。

开始在上下文中绘制后,视图/图层将始终更新其内容。

于 2010-06-03T10:14:43.020 回答