簡體   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