简体   繁体   English

UIImageView跟随另一个UIImageView Swift

[英]UIImageView Following Another UIImageView Swift

If there is an answer which covers my question, please give me a link to it. 如果有涵盖我问题的答案,请给我链接。 Otherwise here is my question: 否则这是我的问题:

I am currently running Swift 2.0 (Xcode 7) Sprite Kit Game and would like to know wether it would be possible for a UIImageView to follow another UIImageView . 我目前正在运行Swift 2.0(Xcode 7)Sprite Kit Game,想知道是否有可能UIImageView跟随另一个UIImageView

So when someone swipes in any direction, the first UIImageView will go that direction, and another will follow it like a snake and they all follow the one in front of them. 因此,当某人向任何方向滑动时,第一个UIImageView会朝该方向滑动,另一个人将像蛇一样跟随它,然后他们都跟着前面的那个跟随。

Edit: I would like to work like a snake. 编辑:我想像蛇一样工作。 So I have many UIImageViews which represent body parts of the snake (basically small black dots) and whichever direction the head goes in which is controlled by UISwipeGestureRecogniser the others parts follow. 因此,我有许多UIImageViews代表蛇的身体部位(基本上是黑色的小点),而头部所走的方向由UISwipeGestureRecogniser控制,其他部位也遵循。

The most easy way is to use UIScrollView with pagingEnabled property enabled. 最简单的方法是使用UIScrollView并启用pagingEnabled属性。 At raywenderlich you can find small tutorial. raywenderlich可以找到小型教程。

Much better way is to use UIPageViewController , example 更好的方法是使用UIPageViewController例如

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM