大家好,我是 xcode 的新手,我正在尝试通过更改其图像来为触摸气球设置动画:这是我的代码:现在我面临的问题是它没有动画图像意味着动画计时器不起作用:请指导我应该做什么我会随着时间的推移为图像制作动画:如果我做得不好,那么请指导我如何通过 NSTimer 做到这一点?
-(void)baloonbursting:(UIButton *)button withEvent:(UIEvent *)event{
if ([[UIImage imageNamed:@"redbaloons.png"] isEqual:button.currentImage]) {
NSLog(@"em redbaloons.png");
UIImage *bubbleImage3 = [UIImage imageNamed:@"redburst.png"];
[button setImage:bubbleImage3 forState:UIControlStateNormal];
}
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView animateWithDuration:1.0f animations:^(){
// define animation
if ([[UIImage imageNamed:@"redburst.png"] isEqual:button.currentImage]) {
NSLog(@"em redbaloons.png");
UIImage *bubbleImage3 = [UIImage imageNamed:@"redburst2.png"];
[button setImage:bubbleImage3 forState:UIControlStateNormal];
}
}
completion:^(BOOL finished){
// after the animation is completed call showAnimation again
[UIView animateWithDuration:1.0 delay:0.0 options:UIViewAnimationOptionCurveEaseOut|UIViewAnimationOptionAllowUserInteraction animations:^{
} completion:^(BOOL finished){
if (finished) {
[button removeFromSuperview];
}}];
}];
}