[英]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. 我有四个UIImageViews排成一行,我希望能够从左向右移动图像。 Is there a way to bound the movement to the x-axis (along the image centers) ie moving them only left and right?
有没有办法将移动限制在x轴上(沿着图像中心),即仅左右移动它们? Similar to moving the icons around the screens on an iPhone.
类似于在iPhone的屏幕上移动图标。
I've added a UIPanGestureRecognizer to each of the views which allows me to move them around everywhere on the screen. 我向每个视图添加了一个UIPanGestureRecognizer,使我可以在屏幕上的任何位置移动它们。
Any thoughts? 有什么想法吗?
Well, if you don't want movement on the y axis, don't modify the y axis. 好吧,如果您不想在y轴上移动,请不要修改y轴。 Just change the x coordindate according to the gesture recognizer's movement.
只需根据手势识别器的移动更改x坐标即可。 What exactly is the problem?
到底是什么问题?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.