Мне нравится разрешать повторные клики на UIImageView во время анимации. Я знаю, что вы можете установить опцию в главном анимационном блоке UIViewAnimationOptionAllowUserInteraction, но мне особенно нужна эта опция в блоке завершения. Предполагаемое поведение - щелчок, UIImageView сразу масштабируется в размере, а затем постепенно возвращается к своему первоначальному размеру. К сожалению, поскольку код остается в силе, анимация должна быть завершена, прежде чем можно будет сделать еще один щелчок.
// In viewDidLoad
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(scale:)];
[hiHatImageView addGestureRecognizer:tap];
[hiHatImageView setMultipleTouchEnabled:YES];
[hiHatImageView setUserInteractionEnabled:YES];
-(void)scale:(id)sender{
// Animate size
[UIView animateWithDuration:0.0
delay:0.0
options:UIViewAnimationOptionAllowUserInteraction |UIViewAnimationOptionCurveEaseOut
animations:^{
hiHatImageView.transform = CGAffineTransformMakeScale(1.4, 1.4);
}
completion:^(BOOL finished){
[UIView animateWithDuration:0.5
animations:^{
// Wish to allow user interactions here!
hiHatImageView.transform = CGAffineTransformMakeScale(1, 1);
}];
}
];
}