我有一个TestView继承自,并且使用它的方法UIView在屏幕上绘制所有内容。drawRect
但是如果我不想drawRect在绘制之前清除视图,我使用
self.clearsContextBeforeDrawing = NO;
self.opaque = NO; // also added because the doc says the rect
// passed to drawRect will be filled with
// background color first if it is set to YES
在initWithFrame方法中。
该drawRect方法通过使用调用
[self.view setNeedsDisplay];
在ViewController事件处理程序中。(对于 touchesMoved 事件)
但是,在绘制任何东西之前,一切都被清除了吗?如何让它发挥作用?