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中实现点击、双击、捏、旋转、拖动、划动、长按手势的类和方法介绍的更多相关文章

  1. UI中各种手势的使用点击,捏合,清扫,旋转,平移,边缘移动,长按

    #import "RootViewController.h" @interface RootViewController (){    UIImageView *imageView ...

  2. Swift中对C语言接口缓存的使用以及数组、字符串转为指针类型的方法

    由于Swift编程语言属于上层编程语言,而Swift中由于为了低层的高性能计算接口,所以往往需要C语言中的指针类型,由此,在Swift编程语言刚诞生的时候就有了UnsafePointer与Unsafe ...

  3. [Swift]在Swift中实现自增(++)、自减(--)运算符:利用extension扩展Int类

    自增(++).自减(--)运算符主要用在For循环中,Swift有自己更简易的循环遍历方法,而且类似x- ++x这种代码不易维护. Swift为了营造自己的编码风格,树立自己的代码精神体系,已经不支持 ...

  4. 工作随笔——Swift中的Range和一些字符操作

    截取字符串在Swift中相比OC要复杂很多,主要原因可能还是OC的NSRange的创建方法中参数类型为int,而Swift却对类型要求很严格,int不能作为参数创建Range,这要使用String中的 ...

  5. 使用swift 中的注意,不断完善中

    1. 应该充分利用swfit的新特性 比如如果按照oc里的习惯,调用一个delegate中都optional函数应该这样写 if delegate != nil && delegate ...

  6. Swift中共有74个内建函数

    Swift中共有74个内建函数,但是在Swift官方文档(“The Swift Programming Language”)中只记录了7中.剩下的67个都没有记录.   本文将列举Swift所有的内建 ...

  7. Swift基础--手势识别(双击、捏、旋转、拖动、划动、长按)

    // //  ViewController.swift //  JieUITapGestureRecognizer // //  Created by jiezhang on 14-10-4. //  ...

  8. iphone练习之手势识别(双击、捏、旋转、拖动、划动、长按)UITapGestureRecognizer

    首先新建一个基于Sigle view Application的项目,名为GestureTest;我的项目结构如下: 往viewController.xib文件里拖动一个imageView,并使覆盖整个 ...

  9. iphone手势识别(双击、捏、旋转、拖动、划动、长按)UITapGestureRecognizer

    首先新建一个基于Sigle view Application的项目,名为GestureTest;我的项目结构如下: 往viewController.xib文件里拖动一个imageView,并使覆盖整个 ...

随机推荐

  1. axure RP Pro7.0加载日历控件的步骤

  2. URI、URL、URN

    URI.URL.URN URI(Uniform Resource Identifie):统一资源标识符 URL(Uniform Resource Locator):统一资源定位符 URN(Unifor ...

  3. (转)XML CDATA是什么?

    解析数据 XML 解析器通常情况下会处理XML文档中的所有文本. 当XML元素被解析的时候,XML元素内部的文本也会被解析: <message>This text is also pars ...

  4. Memcached 深度分析

    Memcached是danga.com(运营LiveJournal的技术团队)开发的一套分布式内存对象缓存系统,用于在动态系统中减少数据库 负载,提升性能.关于这个东西,相信很多人都用过,本文意在通过 ...

  5. C#基础学习第三天(.net菜鸟的成长之路-零基础到精通)

    1.复合赋值运算符 += -= *= /= %= 2.关系运算符  > < >= <= == !=  由关系运算符连接的表达式我们称之为关系表达式.  每一个表达式都可以求解出 ...

  6. oracle 空置排在最后显示

    nulls last select * from emp order by comm select * from emp order by comm desc select * from emp or ...

  7. C++拾遗(十)类与动态内存分配(2)

    静态成员函数 声明时包含关键字static.注意以下两点: 1.使用静态成员函数时不能通过对象或者this指针来调用,只能使用类名+作用域解析符来调用. 2.静态成员函数只能使用静态成员. new操作 ...

  8. trident教程

      (一)理论基础更多理论以后再补充,或者参考书籍1.trident是什么?Trident is a high-level abstraction for doing realtime computi ...

  9. 由浅入深完全掌握Ajax

    n年前,如果不知道 XML,您就是一只无人重视的丑小鸭.十八个月前,Ruby 成了关注的中心,不知道 Ruby 的程序员只能坐冷板凳了.今天,如果想跟上最新的技术时尚,那您的目标就是 Ajax. 但是 ...

  10. 解决animate动画连续播放bug

    在animate动画中,如果几个div之间频繁切换,会导致鼠标移开后,动画仍在继续,解决方法有两个 一个,判断当前是否在运行动画: if(!$(".block").is(" ...