calayer setneedsdisplay instant call drawlayer:incontext
i have a layer called basicLayer, and i have some paths need drawing in function drawlayer:incontext, so i called [basicLayer setneedsdisplay]; which will call drawlayer:incontext atomaticlly, but it didn't called drawlayer:incontext instan开发者_JS百科tlly, so my question is how can i instantlly call drawlayer:incontext after [basicLayer setneedsdisplay]; this consumed me serval hours, please help me?
[basicLayer setNeedsLayout];
[NSThread sleepForTimeInterval:1.0];
i need draw some paths and then sleep 1 seconds.
Don't do this! Calling sleepForTimeInterval:
is generally not a good idea. Especially on the main thread (where I assume you are) it's an absolute no-go because you are blocking the entire UI that way.
If you need to wait for a second, do something like performSelector:withObject:afterDelay
(or an equivalent call with Grand Central Dispatch). The call to setNeedsLayout
is fine.
精彩评论