我正在 UIView 上画一条线。当我调用 -setNeedsDisplay 时,我的 View 变得清晰并绘制新线。如何继续当前行?以及如何用动画绘制?谢谢。
- (void)drawRect:(CGRect)rect {
[super drawRect:rect];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetStrokeColorWithColor(context, [_color CGColor]);
CGContextSetLineWidth(context, 10.0);
CGContextMoveToPoint(context, _startPointX, 0);
CGContextAddLineToPoint(context, _endPointX, 0);
CGContextStrokePath(context);
}
最佳答案
setNeedsDisplay 完全重绘 View 。因此,您需要将所有绘图存储在某处并在每次重绘时应用它。 动画绘图是什么意思?动画绘图就是绘图本身。只需在每次微小更改后重新绘制 View ,看起来就像您自然地绘制一样。
关于ios - 怎么画的时候不清空UIView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22553662/