如何使用捏缩放(UIPinchGestureRecognizer)来更改 UITextView 的宽度?
我可以让 UIPinchGestureRecognizer
处理程序来缩放对象,但我不想缩放,我想更改大小。例如,我有一个 UITextView,并附加了一个 UIPinchGestureRecognizer 手势,如果用户捏合,我想更改文本视图的宽度以匹配捏合。我不想缩放它,因此 UITextView
更大(缩放)。
I can get the UIPinchGestureRecognizer
handler to work with scaling an object but I don't want to scale I want to change the size. For example I have a UITextView
and I've attached a UIPinchGestureRecognizer
gesture to it and if the user pinches I want to change the width of the textview to match the pinch. I don't want to scale it so the UITextView
is larger(zooming).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我也在做同样的事情。
如果我发现如何做到这一点,我会更新这篇文章。
试试这个,它对我有用(对于 UIView):
I am doing the very same thing.
I will update this post if I found how to do it.
Try this, it work for me (for UIView):
你必须快速使用:
You have to use in swift:
我认为你想要做的只是将 textView 框架的宽度乘以手势识别器的比例:
或者这不是你的意思?
I think what you want to do is just multiplying the width of your textView's frame with the gesture recognizer's scale:
Or isn't this what you mean?
我有四个处理文本字段收缩的例程。手势识别器是核心例程。它会查看选定的文本字段是否会被捏出屏幕,我不希望这样。如果不是,那么我会告诉它用手势中的刻度来捏自己。如果选择了多个,我会向那些不会在屏幕上捏自己的人发送通知。
I have four routines that deal with pinching of a text field. The gesture recognizer is the core routine. It sees if the selected text field(s) are going to be Pinched off the Screen, I don't want that. If they are not, then I tell it to pinch itself with the scale from the gesture. If there are multiple selected I send a Notification for those that won't pinch off screen to Pinch themselves.