ytyubox / YuBlog

這是用來記錄的Blog,紀錄內容在 Issues 頁面中。
0 stars 0 forks source link

20190323 長按的想法 #13

Open ytyubox opened 5 years ago

ytyubox commented 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
    }
  }