想要使用 UISwipeGesture 在 NSArray 中的图片之间平滑过渡或滑动 [英] Want smooth transition or slide between pictures in an NSArray using UISwipeGesture

查看:21
本文介绍了想要使用 UISwipeGesture 在 NSArray 中的图片之间平滑过渡或滑动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 UIImageView 作为我的 tabbarcontroller 视图之一,并且我添加了一个 UISwipeGestureRecognizer(左右)来浏览 NSArray 中的一系列照片.

I have a UIImageView as one of my tabbarcontroller views, and I've added a UISwipeGestureRecognizer (right and left) to navigate through a series of photos in an NSArray.

但是,当滑动时,它会从一张照片跳到另一张照片,没有平滑的过渡.我不追求任何花哨的东西,但即使是幻灯片动画也可以,就像一张照片滑入,另一张滑出另一边.这可以通过 UISwipeGestureRecgonizer 和 NSArray 实现吗?

However, when swiping it jumps from photo to photo with no smooth transition. I'm not after anything fancy, but even a slide animation would be okay, like as one photo slides in, the other is sliding out the other side. Is this possible with the UISwipeGestureRecgonizer and an NSArray?

推荐答案

标准的解决方案是使用 UIScrollViewpagingEnabled = YES 和滚动内的多个图像视图看法.如果您只想使用一个 UIImageView,请在识别滑动时向图像视图的图层添加过渡动画:

The standard solution is to use a UIScrollView with pagingEnabled = YES and multiple image views inside the scroll view. If you want to work with just one UIImageView, add a transition animation to the image view's layer when you recognize a swipe:

CATransition *animation = [CATransition animation];
animation.duration = 0.5;
animation.type = kCATransitionMoveIn;
animation.subtype = kCATransitionFromRight;
[myImageView.layer addAnimation:animation forKey:@"imageTransition"];
myImageView.image = newImage;

这篇关于想要使用 UISwipeGesture 在 NSArray 中的图片之间平滑过渡或滑动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆