Want smooth transition or slide between pictures in an NSArray using UISwipeGesture

吃可爱长大的小学妹 提交于 2019-11-30 22:17:42

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;

Why do it this way? Why not just use a UIScrollView with pagingEnabled set to YES? Place your image views inside the scrollview, make sure your contentSize's height is the height of the view you're placing the scroll view in, and your width is the width of all your image views side by side, so you can scroll.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!