【问题标题】:How many point move in pinch action?捏动作有多少点移动?
【发布时间】:2018-12-15 11:35:32
【问题描述】:

使用下面的方法检测捏合动作中移动了多少点(使用UIPinchGestureRecognizer),我必须在iOS设备屏幕上获取点移动视图的值。

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {

}

【问题讨论】:

标签: ios swift gesture uipinchgesturerecognizer


【解决方案1】:

在创建一个全局变量oldPoint之前,使用下面的02委托方法来获取在捏动作中移动了多少点。

var oldPoint = CGPoint()

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        print("touchesBegan")


        let touch : UITouch = touches.first!
        self.oldPoint = touch.location(in: self.viewAnimate)
    }

    override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
        print("touchesMoved")
        StartRecording()

        let touch : UITouch = touches.first!
        let newPoint = touch.location(in: self.viewPinch)

        print("oldPoint : \(oldPoint)")
        print("newPoint : \(newPoint)")
}

你会得到输出日志,

touchesBegan
touchesMoved
oldPoint : (54.0, 55.0)
newPoint : (52.0, 52.0)
touchesMoved
oldPoint : (54.0, 55.0)
newPoint : (52.0, 51.0)
touchesMoved
oldPoint : (54.0, 55.0)
newPoint : (52.0, 49.0)
touchesMoved
oldPoint : (54.0, 55.0)
newPoint : (52.0, 48.0)
猜你喜欢
  • 1970-01-01
  • 2023-03-27
  • 2019-04-24
  • 1970-01-01
  • 1970-01-01
  • 2012-04-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多