有没有办法在不刷新当前UIView的情况下退出drawRect:?例如:
- (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:
}谢谢!
发布于 2010-06-03 18:14:43
如果您还没有开始绘制上下文,那么可以直接从drawRect:返回。您必须在此之前将视图的clearsContextBeforeDrawing属性设置为NO。
开始在上下文中绘制后,视图/层将始终更新其内容。
https://stackoverflow.com/questions/2964894
复制相似问题