Animation with CGPoint in for loop

Posted by user1066524 on Stack Overflow See other posts from Stack Overflow or by user1066524
Published on 2012-12-11T22:53:12Z Indexed on 2012/12/11 23:03 UTC
Read the original article Hit count: 156

Filed under:
|
|
|

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?

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about xcode