UIViewのトランジション
UIViewには次の5つが用意されている。
typedef enum {
UIViewAnimationTransitionNone,
UIViewAnimationTransitionFlipFromLeft,
UIViewAnimationTransitionFlipFromRight,
UIViewAnimationTransitionCurlUp,
UIViewAnimationTransitionCurlDown,
} UIViewAnimationTransition;
これらを見ることのできるサンプルを作った。
FlipFromLeft
CurlUp
ソースコード
アニメーション部分だけ抜き出すとこんな感じ。
- (void)doTransition:(UIViewAnimationTransition)transition
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationTransition:transition
forView:self.imageView
cache:NO];
[UIView setAnimationDuration:self.slider.value];
imageIndex = (imageIndex+1)%8;
self.imageView.image = [self.images objectAtIndex:imageIndex];
[UIView commitAnimations];
}
-(IBAction)none:(id)sender
{
[self doTransition:UIViewAnimationTransitionNone];
}
:
:UIImageView を1枚用意しておき、アニメーションのトランザクション内でトランジションタイプを設定し、画像を入れ替えるだけ。実に簡単だ。
GitHub からどうぞ。
TransitionSample at 2010-09-30 from xcatsan's iOS-Sample-Code - GitHub
参考情報
C開発者によるiPhoneプログラミング: UIViewクラスで裏返したりめくったり
UIView Class Reference
- - - -
簡単だがこの方法だとディゾルブ(フェードイン・フェードアウトを組み合わせて画像を入れ替える)はできない。CATransition を使うとこれができる。






Responses
Leave a Response