程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 更多關於編程 >> Swift中完成點擊、雙擊、捏、扭轉、拖動、劃動、長按手勢的類和辦法引見

Swift中完成點擊、雙擊、捏、扭轉、拖動、劃動、長按手勢的類和辦法引見

編輯:更多關於編程

Swift中完成點擊、雙擊、捏、扭轉、拖動、劃動、長按手勢的類和辦法引見。本站提示廣大學習愛好者:(Swift中完成點擊、雙擊、捏、扭轉、拖動、劃動、長按手勢的類和辦法引見)文章只能為提供參考,不一定能成為您想要的結果。以下是Swift中完成點擊、雙擊、捏、扭轉、拖動、劃動、長按手勢的類和辦法引見正文


1.UITapGestureRecognizer 點擊/雙擊手勢

var tapGesture = UITapGestureRecognizer(target: self, action: "handleTapGesture:") 
//設置手勢點擊數,雙擊:點2下 
tapGesture.numberOfTapsRequired = 2 
self.view.addGestureRecognizer(tapGesture)

2.UIPinchGestureRecognizer 捏 (縮小/減少)手勢

var pinchGesture = UIPinchGestureRecognizer(target: self, action: "handlePinchGesture:") 
self.view.addGestureRecognizer(pinchGesture)

3.UIRotationGestureRecognizer 扭轉手勢

var rotateGesture = UIRotationGestureRecognizer(target: self, action: "handleRotateGesture:") 
 self.view.addGestureRecognizer(rotateGesture) 

4. UIPanGestureRecognizer 拖著手勢

 var panGesture = UIPanGestureRecognizer(target: self, action: "handlePanGesture:") 
 self.view.addGestureRecognizer(panGesture) 

5. UISwipeGestureRecognizer 劃著手勢

var swipeGesture = UISwipeGestureRecognizer(target: self, action: "handleSwipeGesture:") 
swipeGesture.direction = UISwipeGestureRecognizerDirection.Left //不設置是右 
self.view.addGestureRecognizer(swipeGesture)

6. UILongPressGestureRecognizer 長按手勢

   var longpressGesutre = UILongPressGestureRecognizer(target: self, action: "handleLongpressGesture:") 
    //長按時光 
    // longpressGesutre.minimumPressDuration
    //所需觸摸次數
    /// longpressGesutre.numberOfTouchesRequired 
    self.view.addGestureRecognizer(longpressGesutre) 
UIGestureRecognizerState 列舉界說以下

enum UIGestureRecognizerState : Int {

    case Possible // the recognizer has not yet recognized its gesture, but may be evaluating touch events. this is the default state

    case Began // the recognizer has received touches recognized as the gesture. the action method will be called at the next turn of the run loop
    case Changed // the recognizer has received touches recognized as a change to the gesture. the action method will be called at the next turn of the run loop
    case Ended // the recognizer has received touches recognized as the end of the gesture. the action method will be called at the next turn of the run loop and the recognizer will be reset to UIGestureRecognizerStatePossible
    case Cancelled // the recognizer has received touches resulting in the cancellation of the gesture. the action method will be called at the next turn of the run loop. the recognizer will be reset to UIGestureRecognizerStatePossible

    case Failed // the recognizer has received a touch sequence that can not be recognized as the gesture. the action method will not be called and the recognizer will be reset to UIGestureRecognizerStatePossible
}

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved