ビュー コントローラーを作成し、そこに UIImageView を配置しNSArray
、画像を含む を作成して を渡し、左右のスワイプ用UIImageView
に を追加しました。UISwipeGestureRecognizer
このコードは機能しますが、エフェクトやトランジションなしでブームのようにスワイプすると画像が表示されます。それらの間に簡単なトランジションを追加する方法はありますか?
コードは次のとおりです。
NSArray *images = [[NSArray alloc] initWithObjects:
@"1-r.png",
@"2-r.png",
@"3-r.png",
@"4-r.png",
@"5-r.png",
nil];
UISwipeGestureRecognizerDirection direction = [(UISwipeGestureRecognizer *)sender direction];
switch (direction) {
case UISwipeGestureRecognizerDirectionLeft:
imageIndex++;
break;
case UISwipeGestureRecognizerDirectionRight:
imageIndex--;
break;
default:
break;
}
imageIndex = (imageIndex < 0) ? ([images count] - 1) : imageIndex % [images count];
_imageView.image = [UIImage imageNamed:[images objectAtIndex:imageIndex]];