for(NSInteger i = 0; i < 10; i++)
{
....
singleThread = [[NSThread alloc] initWithTarget:self selector:@selector(changeLayerBackground) object:nil];
[singleThread start];
}
函数 changeLayerBackground 像这样:
- (void) changeLayerBackground
{
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"backgroundColor"];
animation.delegate = self;
......
[layer addAnimation:selectionAnimation forKey:@"animation"];
}
我发现animationDidStop:finished:
只有在整个循环完成后才调用该函数。
有人对此有任何想法吗?
现在,我认为这是因为动画的委托是自我,即视图控制器。并且动画是由线程调用的,所以委托不起作用。但我不知道如何改变它。我尝试使用线程作为替代,它仍然不起作用。
任何机构都可以帮助我吗?
我的目标是当动画被调用时,循环应该暂停,直到动画完成,然后循环应该继续。直到循环结束。