CATransaction completion being called immediately

前端 未结 4 2169
盖世英雄少女心
盖世英雄少女心 2020-12-13 12:21

I\'m trying to execute a completion-block after my CAAnimation has finished. However, it seems that animation block is called before my animation completes. The animation st

4条回答
  •  抹茶落季
    2020-12-13 13:13

    I'm not sure if this really is the correct fix, but by setting the completion-block before adding the animation for the layer, the completion-block is consistently called at the correct time.

    [CATransaction begin];
    [CATransaction setCompletionBlock:completionBlock];
    [self.view.layer addAnimation:self.dropAndBounceAnimation forKey:@"appearance"];
    [CATransaction commit];
    

提交回复
热议问题