最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Swift中實(shí)現(xiàn)點(diǎn)擊、雙擊、捏、旋轉(zhuǎn)、拖動(dòng)、劃動(dòng)、長(zhǎng)按手勢(shì)的類(lèi)和方法介紹

 更新時(shí)間:2015年01月09日 12:46:34   投稿:junjie  
這篇文章主要介紹了Swift中實(shí)現(xiàn)點(diǎn)擊、雙擊、捏、旋轉(zhuǎn)、拖動(dòng)、劃動(dòng)、長(zhǎng)按手勢(shì)的類(lèi)和方法介紹,本文分別給出了各種手勢(shì)的實(shí)現(xiàn)代碼,需要的朋友可以參考下

1.UITapGestureRecognizer 點(diǎn)擊/雙擊手勢(shì)

復(fù)制代碼 代碼如下:

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

2.UIPinchGestureRecognizer 捏 (放大/縮小)手勢(shì)
復(fù)制代碼 代碼如下:

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

3.UIRotationGestureRecognizer 旋轉(zhuǎn)手勢(shì)
復(fù)制代碼 代碼如下:

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

4. UIPanGestureRecognizer 拖動(dòng)手勢(shì)
復(fù)制代碼 代碼如下:

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

5. UISwipeGestureRecognizer 劃動(dòng)手勢(shì)
復(fù)制代碼 代碼如下:

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

6. UILongPressGestureRecognizer 長(zhǎng)按手勢(shì)
復(fù)制代碼 代碼如下:

   var longpressGesutre = UILongPressGestureRecognizer(target: self, action: "handleLongpressGesture:") 
    //長(zhǎng)按時(shí)間 
    // longpressGesutre.minimumPressDuration
    //所需觸摸次數(shù)
    /// 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
}

相關(guān)文章

最新評(píng)論

丘北县| 安岳县| 台北县| 大厂| 阳西县| 兴海县| 宜兴市| 乐平市| 鲜城| 定远县| 合江县| 天祝| 诸暨市| 永丰县| 平山县| 永清县| 澳门| 句容市| 喀喇沁旗| 临泉县| 佛坪县| 绩溪县| 盐山县| 韶关市| 固始县| 水富县| 芜湖县| 巫溪县| 绥中县| 雅江县| 赞皇县| 大关县| 周口市| 银川市| 晋城| 竹溪县| 精河县| 彰化市| 农安县| 水富县| 汕头市|