繁体   English   中英

UIView动画完成块立即执行

[英]UIView animation completion block execute immediately

-(void)methodXXXX {

       [UIView animateWithDuration:11 animations:^{
               //...some animation changes...
            } completion:^(BOOL finished) {
                  [_fallBtn removeFromSuperview];
                  _fallBtn = nil;
            }
       }];
}

我在-viewDidAppear处调用此方法,而它直接调用完成块

为什么? 我错过了什么奇怪的东西吗?

我发现了另一件事:

CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
    pathAnimation.calculationMode = kCAAnimationPaced;
    pathAnimation.fillMode = kCAFillModeForwards;
    pathAnimation.removedOnCompletion = YES; //If set YES, it will directly call -animationDidStop method; if NO, the animation execute while never call -animationDidStop
    pathAnimation.duration = 10;
    pathAnimation.delegate = self; //here I implement the -animationDidStop method

使用下面的代码。

-(void)viewDidAppear:(BOOL)animated {
         [self performSelector:@selector(methodXXXX) withObject:nil afterDelay:0.1f];
    }

-(void)methodXXXX {

    [UIView animateWithDuration:11 animations:^
            //...some animation changes...
        } completion:^(BOOL finished) {
            [_fallBtn removeFromSuperview];
            _fallBtn = nil;
    }];
}
[UIView animateWithDuration:11 delay:"add some delay and try" options:0 animations:^{

} completion:^(BOOL finished) {

}];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM