こんにちは皆さん、私は 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];
}}];
}];
}