开发者

Wait during iPhone UI modification

I am making modifications to elements on UI. There is no (extra) thread or any async. calls. However I want to give a slo开发者_JS百科w motion effect, so wait specific time at each step in a for loop. How can I achieve this without blocking the UI?

Specifically, I am moving a button in a for loop. I can put

 [NSThread sleepForTimeInterval:5.0];

in the loop but button's position is not reflected on the UI until the loop ends; I think I should call something to 'redraw' the button at each for iteration.

Any ideas?


Better to use Core Animation if the modifications you are making are to animatable properties. For example, if you want to slowly change the frame of a view, you might do something like:

[UIView beginAnimations:@""];
[UIView setAnimationDuration:5.0];
view.frame = CGRectMake(0, 0, 320, 460);
[UIView commitAnimations];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜