[iOS]CoreAnimation(flip view)
画面に表示する画像を差し替える場合、カードをめくるような効果を使える例だ。
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
[UIView beginAnimations:@"flip view" context:nil];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
forView:self.imageView
cache:YES];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:1.0];
if (self.isAtMark) {
self.isAtMark = NO;
self.imageView.image = self.arrowImage;
}
else {
self.isAtMark = YES;
self.imageView.image = self.atmarkImage;
}
[UIView commitAnimations];
}
前回の例との差は、transitionとタイミングの指定の追加だ。
ソースコード
GitHubからどうぞ。
https://github.com/murakami/workbook/tree/master/ios/CoreAnimation - GitHub
関連情報
Core Animation for Mac OS X and the iPhone
Creating Compelling Dynamic User Interfaces
Core Animationプログラミングガイド
アニメーションのタイプとタイミング
iOS Developer Libraryの翻訳文書だ。