Does anybody here know whether setNeedsDisplay
results in an immediate drawRect
call and immediate updating of the screen?
Or is it merely a queued request?
Thanks.
Asked
Active
Viewed 4,989 times
1 Answers
4
The view is not actually redrawn until the next drawing cycle. This simply notifies the system that the view should be redrawn.
You can apparently accomplish this by setting the content mode to UIViewContentModeRedraw
. I haven't done this personally, but the code should be something along the lines of
UIView *redrawView = [[UIView alloc] initWithFrame:frame];
...
redrawView.contentMode = UIViewContentModeRedraw;

Jason George
- 6,992
- 8
- 44
- 60
-
Do you have any idea how I can force a redraw to happen immediately? Thanks. – Hupe Aug 24 '11 at 21:33
-
setting the contentMode to UIViewContentModeRedraw doesn't in my tests cause an immediate redraw after setNeedsDisplay, only when the bounds change. so I suppose you could jigger the bounds? – natbro Apr 10 '12 at 17:37
-
You might also look here http://stackoverflow.com/questions/1503761/what-is-the-most-robust-way-to-force-a-uiview-to-redraw – Jason George Apr 26 '12 at 06:06