开发者

calayer setneedsdisplay instant call drawlayer:incontext

开发者 https://www.devze.com 2023-03-10 09:42 出处:网络
i have a layer called basicLayer, and i have some paths need drawing in function 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号