I'm trying to do a customized animation on view opacity like this:
I want to repeat step 1 to 4 indefinitely: 1, 2, 3, 4, 1, 2, 3, 4,.....
Here is what I tried:
[UIView animateWithDuration:1
delay:5
options:UIViewAnimationOptionAutoreverse|UIViewAnimationOptionRepeat|UIViewAnimationOptionCurveEaseInOut
animations:^{
self.imageView.layer.opacity = 0;
}
completion:nil
];
But the delay only appeared once at the beginning, what I ended up with is:
1, 2, 4, 2, 4, 2, 4,.....
I had the same problem. I solved in this way, with use of NSTimer
[NSTimer scheduledTimerWithTimeInterval: 2
target: self
selector:@selector(moveImage: )
userInfo: nil repeats:YES];
}
-(void) moveImage: (NSTimer*)timer {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2];