Animation with CGPoint in for loop
- by user1066524
I'm trying to do an animation where when a person clicks from point A to Point B on screen the object should slowly slide straight across (horizontally) from point A to Point B. I tried doing a for loop with something like:
for (CGFloat i=previousPoint.x; i <= newPoint.x; i++){
[UIView animateWithDuration:10
delay:0
options:nil
animations:^ {
[magnifier removeFromSuperview];
magnifier = [[MagnifierView alloc] init];
CGPoint np = {i, newPoint.y};
magnifier.viewToMagnify = imageView;
magnifier.touchPoint = np;
[imageView addSubview:magnifier];
[magnifier setNeedsDisplay];
}
completion:^(BOOL finished) {
}];
}
but for some reason it is moving it way up and then eventually to point B. sort of in a weird curve.
how can I do this correctly?