IOS 自定义手势方向
来源:互联网 发布:proteus仿真软件下载 编辑:程序博客网 时间:2024/05/21 12:34
//自定义一个类继承于 UIPanGestureRecognizer
-(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent *)event{
UITouch *touch=[touchesanyObject];
startPoint=[touchlocationInView:self.view];
_curPoint = startPoint;
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch=[touchesanyObject];
endPoint=[touchlocationInView:self.view];
self.curPoint =endPoint;
CGFloat moveAmtX =endPoint.x -startPoint.x;
CGFloat moveAmtY =endPoint.y -startPoint.y;
self.curMoveAmtX = moveAmtX;
self.curMoveAmtY = moveAmtY;
CGFloat moveAmtYAbs =fabs(moveAmtY);
//斜边
CGFloat moveHypotenuse =sqrt(moveAmtX*moveAmtX + moveAmtY*moveAmtY);
// 1.57 0.785
CGFloat rate = moveAmtYAbs*1.0/moveHypotenuse;
//通过调这个rate值来定义你想触发的手势方向的作用范围.
if(asin(rate) >=1.0){
[selfsetState:UIGestureRecognizerStateChanged];
}else{
return ;
}
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
startPoint=CGPointZero;
_curPoint = startPoint;
[selfsetState:UIGestureRecognizerStateEnded];
return ;
}
- IOS 自定义手势方向
- iOS四个方向的手势
- iOS 自定义手势
- iOS-自定义手势操作
- iOS开发之自定义手势
- iOS手势(拖动,缩放,旋转,点击,手势依赖,自定义手势)
- iOS 手势重叠 iOS系统手势与自定义手势重叠, 手势冲突
- ios学习笔记3 平移的手势的方向
- iOS手势识别:识别原理和自定义手势识别
- iOS手势识别的详细使用(拖动,缩放,旋转,点击,手势依赖,自定义手势)
- iOS手势识别的详细使用(拖动,缩放,旋转,点击,手势依赖,自定义手势)
- iOS手势识别的详细使用(拖动,缩放,旋转,点击,手势依赖,自定义手势)
- iOS手势识别的详细使用(拖动,缩放,旋转,点击,手势依赖,自定义手势)
- iOS手势识别的详细使用(拖动,缩放,旋转,点击,手势依赖,自定义手势)
- iOS手势识别的详细使用(拖动,缩放,旋转,点击,手势依赖,自定义手势)
- iOS手势识别的详细使用(拖动,缩放,旋转,点击,手势依赖,自定义手势)
- iOS手势识别的详细使用(拖动,缩放,旋转,点击,手势依赖,自定义手势)
- iOS手势识别的详细使用(拖动,缩放,旋转,点击,手势依赖,自定义手势)
- OnPaint()函数的作用原理
- MFC笔记 启动其他外部exe程序实现
- 发现csdn博客显示不正常
- 获取网上图片压缩显示
- 怎么判断应用运行在前台还是后台?
- IOS 自定义手势方向
- 李云的25条职场发展原则
- Yahoo!数据中心用户超8亿运维仅百人
- 《Machine Learning in Action》 读书笔记之五:AdaBoost Classification
- 发布MVC 到IIS6.0 碰到的问题
- Ubuntu亲自手动编译Openwrt (DreamBox): for njit....ipk
- 基于扩展INT 13H的光驱引导程序设计
- 四个热门云计算认证可称为高薪利器
- STM32开发环境(工具)之Keil MDK 介绍