UIView: how to do non-destructive drawing?

前端 未结 4 632
[愿得一人]
[愿得一人] 2020-12-08 08:03

My original question:

I\'m creating a simple drawing application and need to be able to draw over existing, previously drawn content in my d

4条回答
  •  有刺的猬
    2020-12-08 08:54

    This prevents your view from being erased before drawRect is done:

    [self.layer setNeedsDisplay];
    

    Also, I find it is better to do all the drawing in the drawRect method (unless you have a good reason not to). Drawing offscreen and transferring takes more time and adds more complexity then simply drawing everything once.

提交回复
热议问题