实现可以触摸拉伸和旋转的UIView [英] Implementing a UIView that can stretch and rotate with touches

查看:30
本文介绍了实现可以触摸拉伸和旋转的UIView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实现执行以下操作的矩形视图.当用户从左侧或右侧拖动矩形视图时,它的拉伸如下:

I'm trying to implement a rectangular view that does the following. When the user drags the rectangular view from the left or right, it stretches as below:

当用户在UIView上上拉或下拉时,其旋转如下:

When the user pulls up or down on the UIView, it rotates as below:

想知道是否有人可以给我提供有关如何实现此目标的线索.我不相信您可以使用手势识别器来做到这一点.有人知道吗?

Wondering if someone can give me a clue on how to implement this. I don't believe you can do it with gesture recognizers. Does anyone know?

更新:假设没有旋转,这样做实际上很不错.您可以按用户向左或向右拖动的量拉伸它,也可以按用户向上拉的量旋转它.但是,旋转视图时,由于点改变,因此该方法不再起作用.对如何执行此操作有任何想法吗?

UPDATE: This is actually not bad to do assuming there is no rotation. You can just stretch it by the amount the user dragged left or right, or rotate it by the amount they pulled it up. However, when the view is rotated, this methodology no longer works since the points change. Any idea on how to execute this?

推荐答案

我有一个Github项目,该项目显示了如何轻松使用每种类型的UIGesture,包括缩放大小和旋转.

I have a Github project that shows how to easily use each type of UIGesture including pinch resizing and rotation.

签出收缩",旋转"和同时"部分.我想您会找到所需的东西.

Checkout the Pinch, Rotate, and Simultaneous sections. I think you'll find exactly what you're looking for.

https://github.com/EmperiorEric/UIGestures

这篇关于实现可以触摸拉伸和旋转的UIView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆