setNeedsDisplayInRect: paints a white rectangle only
- by Ion Tichy
Hi,
I'm still a little fresh to CoreGraphics programming, so please bear with me. I'm trying to write an application, which allows the user to rub stuff off an image with the finger. I have the basic functionality nailed down, but the result is sluggish since the screen is redrawn completely every time a touch is rendered. I did some research and found out that I can refresh only a portion of the screen using UIView's setNeedsDisplayInRect: method.
This does call drawRect: as expected, however everything I draw in the drawRect: following the setNeedsDisplayInRect: is ignored. Instead, the area in the rect parameter is simply filled with white. No matter what I draw inside, all I end up with is a white rectangle.
In essence, this is what I do:
1) when user touches screen, this touch is rendered into a mask
2) when the drawRect: is called, the image is masked with that mask
There must be something simple I'm overlooking, surely?