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’m new at animations by the way.
[UIView animateWithDuration:10
delay:0
options:nil
animations:^ {
if(magnifier != nil){
[magnifier removeFromSuperview];
}
magnifier = [[MagnifierView alloc] init];
magnifier.viewToMagnify = imageView;
magnifier.touchPoint = newPoint;
[imageView addSubview:magnifier];
[magnifier setNeedsDisplay];
}
completion:nil];
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?
Don’t use a loop. Just use the animation block that you have.
Example:
Also for options you can set
UIViewAnimationOptionCurveEaseInOutif you want an easing effect at the beginning and end of the animation orUIViewAnimationOptionCurveLinearif you want an equally timed animation with no easing (there are others available, look up UIViewAnimationOptions).