麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 編程 > Swift > 正文

Swift中實現點擊、雙擊、捏、旋轉、拖動、劃動、長按手勢的類和方法介紹

2020-03-09 17:51:43
字體:
來源:轉載
供稿:網友
這篇文章主要介紹了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
}



注:相關教程知識閱讀請移步到swift教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 精品在线视频观看 | 91av日韩| av之家在线观看 | a黄在线观看 | 免费国产一级淫片 | 视频一区二区久久 | 亚洲日韩精品欧美一区二区 | 国产美女的小嫩bbb图片 | 久久精片 | 圆产精品久久久久久久久久久 | 国产剧情在线观看一区二区 | 欧美视频网 | 国产毛片aaa一区二区三区视频 | 免费在线观看亚洲 | 香蕉久久久久久 | 国产在线a | 特大黑人videos与另类娇小 | 美女污污视频在线观看 | 色综合久久久久久久粉嫩 | qyl在线视频精品免费观看 | 日日摸夜夜添夜夜添牛牛 | 国产毛片网 | 欧美日韩国产一区二区三区在线观看 | 性生活视频软件 | 亚洲小视频在线 | 欧美不卡视频在线观看 | 精品国产一区二区三区久久久蜜月 | 特一级毛片 | 91 在线观看 | 九九热九九爱 | 欧美a视频在线观看 | 未成年人在线观看 | 一区二区三区欧洲 | 色中色综合| 热99re久久免费视精品频软件 | 日本视频免费观看 | 亚洲一区二区网址 | 久久久久久久久久网 | 国产做爰| 性少妇videosexfreexxx片 | 精品一区二区三区中文字幕老牛 |