[UIView animateWithDuration:1 animations:^{
self.animateView.frame = CGRectMake(100, 100, 50, 50);
} completion:^(BOOL finished) {
if (finished) {
NSLog(@"animation finished");
}
}];
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1]];
NSLog(@"after runUntilDate");
像上面这么多代码,这是为什么呢?如果我评论 runUntilDate 行会发生什么?
更新:如果我在最后一行添加下一行(NSLog),直到动画完成才会执行。看起来 runUntilDate 阻塞了主线程,那么为什么我们需要在这里阻塞线程呢?