Open ytyubox opened 5 years ago
透過 LastGesture 知道最後手勢的位置,在手勢開始的啟動計時,記得要在手勢結束的時候停止計時。
@objc func handleLongPress(gesture : UILongPressGestureRecognizer!) { lastGesture = gesture switch gesture.state { case .began: timer = Timer.scheduledTimer(timeInterval: 0.5, target: self, selector: #selector(timeUP), userInfo: nil, repeats: false) break case .ended, .cancelled,.failed: timer.invalidate() default: break } }
透過 LastGesture 知道最後手勢的位置,在手勢開始的啟動計時,記得要在手勢結束的時候停止計時。