UI----Touch
2015-10-17 17:51
393 查看
UI—-Touch
触摸开始时调用的方法
触摸结束时调用的方法
触摸移动时调用的方法
触摸中断取消是调用的方法
触摸开始时调用的方法
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ UITouch *touch = [touches anyObject]; CGPoint point = [touch locationInView:self.viewL.touchView]; CGPoint point2 = [touch previousLocationInView:self.viewL.touchView]; NSLog(@"%.2f %.2f",point2.x,point2.y); NSLog(@"%.2f %.2f",point.x,point.y); }
触摸结束时调用的方法
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{ NSLog(@"结束"); }
触摸移动时调用的方法
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{ UITouch *touch = [touches anyObject]; CGPoint point1 = [touch locationInView:self.viewL.touchView]; CGPoint point2 = [touch previousLocationInView:self.viewL.touchView]; // NSLog(@"point1 : %.2f %.2f",point1.x,point1.y); // NSLog(@"point2 : %.2f %.2f",point2.x,point2.y); CGPoint center = self.viewL.touchView.center; CGFloat x = point1.x - point2.x; CGFloat y = point1.y - point2.x; center.x += x; center.y += y; //保持在屏幕内移动 // if (center.x < 100 ) { // center.x = 100; // }else if (center.x > CGRectGetMaxX(self.viewL.frame) - 100){ // center.x = CGRectGetMaxX(self.viewL.frame) - 100; // } // if (center.y < 100) { // center.y = 100; // }else if (center.y > CGRectGetMaxY(self.viewL.frame) - 100){ // center.y = CGRectGetMaxY(self.viewL.frame) - 100; // } self.viewL.touchView.center = CGPointMake(center.x, center.y);
触摸中断取消是调用的方法
// - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{ NSLog(@"cancel %s",__FUNCTION__); }
相关文章推荐
- 定制Segue - OverlaySegue
- EasyUI - pagination 分页组件
- UI--Gesture
- NGUI实现输入框和进度条
- 第一篇 UEditor入门部署和体验
- leetcode : 4 Median of Two Sorted Arrays
- POJ 3368 Frequent values
- 【学习总结】UIGestureRecognizer(手势识别器)
- EasyUI - SplitButton 分割按钮
- Android中bluetooth的架构
- Android Bluetooth蓝牙开发\蓝牙协议\蓝牙通信例子_Android支持蓝牙4.0版本_BLE开发
- EasyUI - Menu 菜单
- UISearchBar自定义取消按钮
- 读《认知与设计:理解UI设计准则》第二章
- EasyUI - Messager消息框
- 使用Autolayout实现UITableView的Cell动态布局和高度动态改变
- 63 Unique Paths II
- Java基础编程8-特殊流程控制语句-continue的用法
- IOS 轮播图(UIScrollView)
- UI基础控件