拖拽view
1.利用touchesMoved事件来实现
-(void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
//NSLog(@"%@",event);
NSLog(@"%@",touches);
UITouch *touch=[touches anyObject];
//CGFloat xMove=[touch locationInView:self].x-[touch preciseLocationInView:self].x;
//CGFloat hMove=[touch locationInView:self].y-[touch preciseLocationInView:self].y;
CGPoint curP=[touch locationInView:self];
// CGPoint prep=[touch preciseLocationInView:self]; 9.0之前
CGPoint preP=[touch precisePreviousLocationInView:self];//9.0之后
CGFloat offsetX=curP.x-preP.x;
CGFloat offsetY=curP.y-preP.y;
NSLog(@"%f %f",curP.x,preP.x);
//NSLog(@"%f,%f",offsetX ,offsetY);
self.transform=CGAffineTransformTranslate(self.transform, offsetX, offsetY);
}