IOS swift多点触控
来源:互联网 发布:linux www服务器搭建 编辑:程序博客网 时间:2024/05/21 02:49
override func viewDidLoad() { super.viewDidLoad() self.view.multipleTouchEnabled=true//是否开启多点触摸 // Do any additional setup after loading the view, typically from a nib. } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) { //获得焦点的坐标// var l:CGPoint=((touches as NSSet).anyObject())!.locationInView(self.view) as CGPoint// println("x:\(l.x),y:\(l.y)")// println("touchesBegan按下") } override func touchesEnded(touches: Set<NSObject>, withEvent event: UIEvent) { // println("touchesEnded抬起") } private var lastDistance:CGFloat = 0.0 override func touchesMoved(touches: Set<NSObject>, withEvent event: UIEvent) {// println(touches.count)// //获得每个焦点// for touche in touches{// //获得焦点的坐标// var l:CGPoint = (touche as AnyObject).locationInView(self.view) as CGPoint// println("x:\(l.x),y:\(l.y)")// }// // println("touchesMoved移动") if touches.count == 2 { var p1:CGPoint=(touches as NSSet).allObjects[0].locationInView(self.view) as CGPoint var p2:CGPoint=(touches as NSSet).allObjects[1].locationInView(self.view) as CGPoint var xx = p1.x - p2.x var yy = p1.y - p2.y var currenDistance:CGFloat=sqrt(xx*xx+yy*yy) if lastDistance == 0.0{ lastDistance = currenDistance }else{ if lastDistance-currenDistance > 3{ println("缩小") image.transform=CGAffineTransformScale(image.transform, 0.9, 0.9) }else if lastDistance-currenDistance < -3{ println("放大") image.transform=CGAffineTransformScale(image.transform, 1.1, 1.1) } lastDistance = currenDistance } } } override func touchesCancelled(touches: Set<NSObject>!, withEvent event: UIEvent!) { // println("touchesCancelled") }
0 0
- IOS swift多点触控
- ios开启多点触控
- iOS 防止多点触控
- ios 模拟器如何模拟多点触控
- ios 模拟器如何模拟多点触控
- cocos2d-x开启IOS多点触控
- cocos2d-x开启IOS多点触控
- ios cocos2d-x 接受多点触控事件
- ios中 默认是不支持多点触控
- Cocos2d-x3.2 iOS下开启多点触控
- Swift 开启多点触摸
- 多点触控
- android多点触控
- Android多点触控
- 多点触控
- 触摸屏多点触控
- android 多点触控
- android 多点触控
- 图解Android View的scrollTo(),scrollBy(),getScrollX(), getScrollY()
- LOG算子的运用
- android 基础知识总结 之 等待圆环
- 2012年5月SAT香港真题解析
- section或cell的使用
- IOS swift多点触控
- String,StringBuffer,StringBuilder的区别
- Windows时间函数
- Android系列之Fragment(一)----Fragment加载到Activity当中
- Eclipse3.4—Eclipse3.7 link方式安装插件
- linux 脚本交互
- JIRA系统部署推进上线流程
- Java学习笔记--------异常处理
- 关于软件基础中为什么使用二级指针的分析