I searched for a lot of SO files and Apple links, but still could not solve my problem.
What I have:
- with two UIImageViews and 2 UIButtons with them
- 2 types of animation:
2.1. the first one is scaled, then down through each image, one after another, only once in viewDidLoad 2.2. second, when a button is pressed (which is a custom button hidden "inside" of each UIImageView), it calls the animation of the corresponding UIImageView - only one, not both (it also scales and then down). - As I write for iOS4 +, they tell me to use block-based animations!
What I need:
How to cancel the start of the animation? I managed to undo everything except the last ...: / Here is my piece of code:
[UIImageView animateWithDuration:2.0 delay:0.1 options:UIViewAnimationOptionAllowUserInteraction animations:^{ isAnimating = YES; self.bigLetter.transform = CGAffineTransformScale(self.bigLetter.transform, 2.0, 2.0); } completion:^(BOOL finished){ if(! finished) return; [UIImageView animateWithDuration:2.0 delay:0.0 options:UIViewAnimationOptionAllowUserInteraction animations:^{ self.bigLetter.transform = CGAffineTransformScale(self.bigLetter.transform, 0.5, 0.5); } completion:^(BOOL finished){ if(! finished) return; [UIImageView animateWithDuration:2.0 delay:0.0 options:UIViewAnimationOptionAllowUserInteraction animations:^{ self.smallLetter.transform = CGAffineTransformScale(self.smallLetter.transform, 2.0, 2.0); } completion:^(BOOL finished){ if(! finished) return; [UIImageView animateWithDuration:2.0 delay:0.0 options:UIViewAnimationOptionAllowUserInteraction animations:^{ self.smallLetter.transform = CGAffineTransformScale(self.smallLetter.transform, 0.5, 0.5); } completion:^(BOOL finished){ if (!finished) return;
Somehow smallLetter UIImageView does not work correctly, when you click (via the button) bigLetter cancels the animation correctly ... thanks in advance :)
EDIT: I used this solution, but still have the problem of reducing the size of the smallLetter UIImageView - it does not cancel at all ....
EDIT2: I added this at the beginning of the following / previous methods:
- (void)stopAnimation:(UIImageView*)source { [UIView animateWithDuration:0.01 delay:0.0 options:(UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionAllowUserInteraction) animations:^ { source.transform = CGAffineTransformIdentity; } completion:NULL ]; }
the problem remains ...: / no idea how to interrupt the last animation for letters in the animation chain
ios iphone animation ios4 uiimageview
raistlin Mar 05 2018-12-12T00: 00Z
source share