使用 UIGestureRecognizer 沿 x 轴移动 UIImageView
我有四个 UIImageView 排成一排,我希望能够从左到右移动图像。有没有办法将运动绑定到 x 轴(沿着图像中心),即仅向左和向右移动它们?类似于在 iPhone 屏幕上移动图标。
我向每个视图添加了一个 UIPanGestureRecognizer,这使我可以将它们移动到屏幕上的任何位置。
有什么想法吗?
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) i.e. 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,如果您不想在 y 轴上移动,请不要修改 y 轴。只需根据手势识别器的移动更改 x 坐标即可。到底是什么问题呢?
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?