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. junit测试用例加载spring配置文件

    junit加载pom引用项目的xml配置文件,如果定义了<beans profile="dev">,必须在测试用例类上面加上标记 @ActiveProfiles(&qu ...

  2. php数组操作函数

    array 详解PHP ob_start()函数的功能要点 http://developer.51cto.com/art/200912/166834.htm http://blog.csdn.net/ ...

  3. C# Gma.QrCodeNet生成二维码

    一.使用C#生成二维码类库之一是qrcodenet 源代码地址: http://qrcodenet.codeplex.com/ 二.使用实例 定义处理字符串 static string url = & ...

  4. __dopostback的用法 . 编辑

    在.NET中,所有的服务器控件提交到服务器的时候,都会调用__doPostBack这个函数,所以灵活运用这个函数对于我们的帮助还是很大的. 比如,在我们写程序的时候经常会需要动态的生成一些控件,最简单 ...

  5. php代码结尾不要添加结尾标记

    如果文件内容是纯 PHP 代码,最好在文件末尾删除 PHP 结束标记.这可以避免在 PHP 结束标记之后万一意外加入了空格或者换行符,会导致 PHP 开始输出这些空白,而脚本中此时并无输出的意图.

  6. Lesson 4: Know Your Tools

    Lesson 4: Know Your Tools "差劲的人

  7. CocoaPods报错:The dependency `xxx` is not used in any concrete target

    官网是这样给推荐的: 在创建Podfile的时候,用这种格式使用, platform :ios, '8.0' use_frameworks! target 'MyApp' do pod 'AFNetw ...

  8. 关于keil单片机编程中的data,idata,xdata,pdata,code数据类型

    从数据存储类型来说,8051系列有片内.片外程序存储器,片内.片外数据存储器,片内程序存储器还分直接寻址区和间接寻址类型,分别对应code.data.xdata.idata以及根据51系列特点而设定的 ...

  9. 你好,C++(25)函数调用和它背后的故事5.1.2 函数调用机制

    5.1.2  函数调用机制 在前面的学习中,我们多次提到了“调用函数”的概念.所谓调用函数,就是将程序的执行控制权从调用者(某个函数)交给被调用的函数,同时通过参数向被调用的函数传递数据,然后程序进入 ...

  10. 如何用PowerPoint制作闪烁的星星

    在PPT中,PPT动画说是幻灯片PPT中的精华是当之无愧的!ppt文件有了动画,犹如插上翅膀的鸟,让PPT的色彩衍生出了更多的特色.只要你的ppt动画效果制作的对,你的幻灯片将明显与众不同,观众也更容 ...