setNeedsDisplayInRect: paints a white rectangle only
Posted
by Ion Tichy
on Stack Overflow
See other posts from Stack Overflow
or by Ion Tichy
Published on 2010-04-06T13:16:58Z
Indexed on
2010/04/13
14:53 UTC
Read the original article
Hit count: 266
iphone
|coregraphics
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?
© Stack Overflow or respective owner