开发者

Rollback drawRect:

开发者 https://www.devze.com 2023-01-01 21:06 出处:网络
Is there any way to quit from drawRect: without refresh the current UIView? For example: - (void)drawRect:(CGRect)rect {

Is there any way to quit from drawRect: without refresh the current UIView? For example:

- (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 w开发者_如何学运维ould like to return from here and rollback all changes in drawRect:

}

Thanks!


If you haven't started drawing into the context, it might be possible to just return from drawRect:. You'd have to set the clearsContextBeforeDrawing property of the view to NO before.

After starting to draw in the context, the view/layer will always update its content.

0

精彩评论

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

关注公众号