访问平移手势的速度 [英] Access the velocity of a pan gesture

查看:33
本文介绍了访问平移手势的速度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得平移手势的速度,我想使用发送者的速度属性,但它似乎不起作用:

I want to get the velocity of a pan gesture, and I thought to use the sender's velocity property, but it doesn't seem to work:

@IBAction func handleGesture(sender: AnyObject) {
    let v = sender.velocity
}

但它抛出一个错误说:

'速度'的模糊使用"

如果这不是访问平移手势速度的方法,那是什么?

If that's not the way to access the velocity of a pan gesture, what is?

推荐答案

UIPanGestureRecognizer 没有名为 velocity 的属性.您应该使用 velocityInView 方法.

UIPanGestureRecognizer does not have property named velocity. You should use velocityInView method.

func userPanned(sender: UIPanGestureRecognizer) {
    let v = sender.velocityInView(self.view)
}

这篇关于访问平移手势的速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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