9.3 触摸和手势:捏合手势
来源:互联网 发布:网络个人研修计划 编辑:程序博客网 时间:2024/04/30 05:19
==========模拟捏合手势===========
#import "TouchView.h"@interface TouchView (){ double lastDistance; }@end@implementation TouchView- (id)initWithFrame:(CGRect)frame{ self = [super initWithFrame:frame]; if (self) { // 开启触摸响应,默认是yes self.userInteractionEnabled = YES; // 开启多点触摸,默认NO; self.multipleTouchEnabled = YES; } return self;}- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ if ([touches count] == 2) { NSArray *touchArray = [touches allObjects]; UITouch *firstTouch = [touchArray objectAtIndex:0]; UITouch *secondTouch = [touchArray objectAtIndex:1]; CGPoint point1 = [firstTouch locationInView:self]; CGPoint point2 = [secondTouch locationInView:self]; double distance = [self distance:point1 point:point2]; NSLog(@"%f", distance); } }// 模拟捏合手势- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{ if ([touches count] == 2) { NSArray *touchArray = [touches allObjects]; UITouch *firstTouch = [touchArray objectAtIndex:0]; UITouch *secondTouch = [touchArray objectAtIndex:1]; CGPoint point1 = [firstTouch locationInView:self]; CGPoint point2 = [secondTouch locationInView:self]; //当前两点的距离 double distance = [self distance:point1 point:point2]; float subValue = distance - lastDistance; if (subValue > 0) { NSLog(@"放大捏合"); }else { NSLog(@"缩小捏合"); } lastDistance = distance; }}- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{ }// 求出两点距离- (double)distance:(CGPoint)p1 point:(CGPoint)p2{ // ((x1-x2)平方+(y1-y2)平方)开方 double distance = sqrt(pow(p1.x - p2.x, 2) + pow(p1.y - p2.y, 2)); return distance;}@end
0 0
- 9.3 触摸和手势:捏合手势
- IOS学习 触摸和手势UITouch 捏合
- 捏合手势
- iOS 手势识别 旋转和缩放(捏合)
- 轻击,触摸和手势
- 触摸事件和手势
- 触摸和手势
- iOS触摸和手势
- 手势和触摸事件
- 手势和触摸事件
- 处理触摸和手势
- 触摸和手势
- 捏合(pinch)手势
- UI 捏合手势
- 创建一个捏合手势
- 触摸手势
- 触摸手势
- IOS触摸事件和手势
- 后缀自动机(SAM)学习指南
- WinCE设备电池电量采集问题
- Java集合源码学习(9)_Set接口的基础实现AbstractSet
- 安全第一篇:学习及工作目标
- expandlistview 加伸缩的动画
- 9.3 触摸和手势:捏合手势
- 停用词stopWord
- 字符串-03. 字符串的冒泡排序(20)
- ASP:如何解决Response.Redirect方法传递汉字丢失或乱码问题?
- Eclipse/MyEclise 自定义注释中的变量名称
- http://www.cnblogs.com/tornadomeet/archive/2012/08/15/2640754.html
- NYOJ 题目171 聪明的kk
- javamail接收邮件(较全)
- PHP的发展趋势