标签:
方法:
//开始接触
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
- //在屏幕上移动
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
- //触摸结束
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
- //取消触摸
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];//得到触摸对象
CGPoint current = [touch locationInView:self];//得到当前触摸所在的点
CGPoint previous = [touch previousLocationInView:self];//得到触摸所在的上一个点
CGPoint center = self.center;//拿到UIView的中点
center.x += current.x - previous.x;
center.y += current.y - previous.y;
self.center = center;
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
}
标签:
原文地址:http://blog.csdn.net/ttf1993/article/details/45824647