когда вы нажимаете пальцем, сохраняете точку
, затем измеряете скорость перетаскивания и применяете скорость к положению вашего вида (я перевожу свой вид с началом координат в моем примере)
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
NSUInteger touchCount = [touches count];
NSUInteger tapCount = [[touches anyObject] tapCount];
NSLog(@"touchesBegan");
NSLog(@"%d touches", touchCount);
NSLog(@"%d taps", tapCount);
UITouch *touch = [touches anyObject];
pNow = [touch locationInView:self];
pLast = [touch locationInView:self];
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
NSUInteger touchCount = [touches count];
NSUInteger tapCount = [[touches anyObject] tapCount];
NSLog(@"touchesMoved");
NSLog(@"%d touches", touchCount);
NSLog(@"%d taps", tapCount);
UITouch *touch = [touches anyObject];
pNow = [touch locationInView:self];
mouseSpeed.x = pNow.x - pLast.x;
mouseSpeed.y = pNow.y - pLast.y;
NSLog(@"mouseSpeed : %f, %f", mouseSpeed.x, mouseSpeed.y);
origin.x += mouseSpeed.x;
origin.y += mouseSpeed.y;
NSLog(@"origin : %f, %f", origin.x, origin.y);
//copy point for the next update
pLast = pNow;
}