简体   繁体   中英

Move UIImageView along the x-axis using a UIGestureRecognizer

I have four UIImageViews lined up in a row and I want to be able to move the images from left to right. Is there a way to bound the movement to the x-axis (along the image centers) ie moving them only left and right? Similar to moving the icons around the screens on an iPhone.

I've added a UIPanGestureRecognizer to each of the views which allows me to move them around everywhere on the screen.

Any thoughts?

Well, if you don't want movement on the y axis, don't modify the y axis. Just change the x coordindate according to the gesture recognizer's movement. What exactly is the problem?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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