Two things:
- You need to initiate the next transition in the completion block of the previous transition to have them happen sequentially.
- You need to use the
UIViewAnimationOptionTransitionCrossDissolve
option, notUIViewAnimationOptionCurveLinear
Here's some code I mocked up to do a sequence of transitions on a label:
@interface ViewController ()
@property (nonatomic) NSInteger iterationCount;
@property (strong, nonatomic) IBOutlet UILabel *label;
@end
@implementation ViewController
// called on button tap
- (IBAction)startTransitioning:(id)sender {
self.iterationCount = 0;
[self iterateTransition];
}
- (void)iterateTransition
{
if (self.iterationCount < 5) {
self.iterationCount++;
[UIView transitionWithView:self.label duration:2 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
self.label.text = [NSString stringWithFormat:@"%d", self.iterationCount];
} completion:^(BOOL finished) {
[self iterateTransition];
}];
} else {
self.iterationCount = 0;
}
}
@end