• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号
您的位置:首页 > 程序设计 >swift > Swift中实现点击、双击、捏、旋转、拖动、划动、长按手势的类和方法介绍

Swift中实现点击、双击、捏、旋转、拖动、划动、长按手势的类和方法介绍

作者: 字体:[增加 减小] 来源:互联网 时间:2017-05-28

通过本文主要向大家介绍了Swift中实现点击、双击、捏、旋转、拖动、划动、长按手势的类和方法介绍等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

1.UITapGestureRecognizer 点击/双击手势
var tapGesture = UITapGestureRecognizer(target: self, action: "handleTapGesture:") 
//设置手势点击数,双击:点2下 
tapGesture.numberOfTapsRequired = 2 
self.view.addGestureRecognizer(tapGesture)
</div>
2.UIPinchGestureRecognizer 捏 (放大/缩小)手势
var pinchGesture = UIPinchGestureRecognizer(target: self, action: "handlePinchGesture:") 
self.view.addGestureRecognizer(pinchGesture)
</div>
3.UIRotationGestureRecognizer 旋转手势
var rotateGesture = UIRotationGestureRecognizer(target: self, action: "handleRotateGesture:") 
 self.view.addGestureRecognizer(rotateGesture) 
</div>
4. UIPanGestureRecognizer 拖动手势
 var panGesture = UIPanGestureRecognizer(target: self, action: "handlePanGesture:") 
 self.view.addGestureRecognizer(panGesture) 
</div>
5. UISwipeGestureRecognizer 划动手势
var swipeGesture = UISwipeGestureRecognizer(target: self, action: "handleSwipeGesture:") 
swipeGesture.direction = UISwipeGestureRecognizerDirection.Left //不设置是右 
self.view.addGestureRecognizer(swipeGesture)
</div>
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
}
</div>

</div>
分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

相关文章

  • 2017-05-28Swift开发之使用UIRefreshControl实现下拉刷新数据及uirefreshcontrol使用
  • 2017-05-28深入解析Swift编程中枚举类型的相关使用
  • 2017-05-28Swift算法之栈和队列的实现方法示例
  • 2017-05-28探讨Swift数组和字典
  • 2017-05-28Swift使用Cocoa中的数据类型教程
  • 2017-05-28Struts2实现单文件或多文件上传功能
  • 2017-05-28struts2实现多文件上传的示例代码
  • 2017-05-28浅谈Timer和TimerTask与线程的关系
  • 2017-05-22Swift 字面量
  • 2017-05-28Swift教程之基本运算符详解

文章分类

  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号

最近更新的内容

    • 浅谈Timer和TimerTask与线程的关系
    • Swift读取App的版本信息与PCH文件详解
    • Swift教程之闭包详解
    • 深入理解Swift中的访问控制关键字
    • ssh框架实现文件上传下载实例代码
    • Swift中内置的集合类型学习笔记
    • 使用Swift实现iOScollectionView广告无限滚动效果(DEMO)
    • 深入解析Swift代理模式
    • Swift编程之枚举类型详解
    • Swift编程中实现希尔排序算法的代码实例

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有