UISwipeGestureRecognizer Swipe length

后端 未结 6 2174
暗喜
暗喜 2020-12-01 00:53

Any idea if there is a way to get the length of a swipe gesture or the touches so that i can calculate the distance?

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-01 01:33

    func swipeAction(gesture: UIPanGestureRecognizer) {
        let transition = sqrt(pow(gesture.translation(in: view).x, 2)
                         + pow(gesture.translation(in: view).y, 2))
    }
    

提交回复
热议问题