ボタンが動いた時のアニメーション
基本的にやるステップは下記のようになる。
・アニメーションさせたいビューのbeginAnimations:context:を呼ぶ
・アニメーションプロパティの設定
・アニメーションさせたいビューのcommitAnimationsを呼ぶ
MoveMeにおけるコードは下記の通り
- (void)animateFirstTouchAtPoint:(CGPoint)touchPoint { #define GROW_ANIMATION_DURATION_SECONDS 0.15 NSValue *touchPointValue = [[NSValue valueWithCGPoint:touchPoint] retain]; [UIView beginAnimations:nil context:touchPointValue]; [UIView setAnimationDuration:GROW_ANIMATION_DURATION_SECONDS]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector: @selector(growAnimationDidStop:finished:context:)]; CGAffineTransform transform = CGAffineTransformMakeScale(1.2, 1.2); placardView.transform = transform; [UIView commitAnimations]; } - (void)growAnimationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context { [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:SHRINK_ANIMATION_DURATION_SECONDS]; placardView.transform = CGAffineTransformMakeScale(1.1, 1.1); [UIView commitAnimations]; }