I wanted to do a small loader animation to put in my app. I have done repeating animations before with CGAnimations without problems, this time I was going for the block approach.
I am doing a small test but can make the following code repeat:
- (void) startLoading {
__block int count = 0;
[UIView animateWithDuration:0.4
delay: 0.0
options: UIViewAnimationOptionRepeat
animations:^{
count++;
}
completion:^(BOOL finished){
if (count > 5)
count = 0;
NSLog(@"%d", count);
}];
}
- (void) stopLoading {
}
The above only fires the completion block once, it does not repeat.
How do I get the block to repeat so that count increments?
If I get this working and put my animation into the repeating block, What goes into stopLoading: to stop the animation again?
Thanks for any help given:)