我有一个TestView继承自UIView,所有内容都使用其drawRect方法绘制在屏幕上。但是如果我不想让drawRect在绘制之前清空View,我使用了self.clearsContextBeforeDrawing=NO;self.opaque=NO;//alsoaddedbecausethedocsaystherect//passedtodrawRectwillbefilledwith//backgroundcolorfirstifitissettoYES在initWithFrame方法中。使用drawRect方法调用[self.viewsetNeedsDisplay];在Vi