Repeat an animation a variable number of times

后端 未结 4 1131

I was wondering how I can set an animation to repeat. The number of repetitions needs to be determined by a variable. In the following code, the variable int newPage

4条回答
  •  盖世英雄少女心
    2021-02-19 10:08

    Had the same problem - you were missing an an'UIViewAnimationOptionRepeat'

    This should work:

     [UIView animateWithDuration:0
                          delay:1
                        options:UIViewAnimationOptionCurveEaseIn | UIViewAnimationOptionRepeat
                     animations:^{
                         [UIView setAnimationRepeatCount:2]; // **This should appear in the beginning of the block**
                         [self animatePage];
    
                     }
                     completion:nil];
    

    Did the trick for me.

提交回复
热议问题