无论如何我可以使我的图像跳跃然后倒退

时间:2014-04-13 16:44:50

标签: ios objective-c gravity

我希望我的图像能够跳起7条y轴线或者其他东西,但是我想让他倒下来。任何帮助?

Heres My Code:

CGRect frame = Guy.frame;
frame.origin.x = frame.origin.x - 0;
frame.origin.y = frame.origin.y - 7;

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.60];
Guy.frame = frame;
[UIView commitAnimations];

3 个答案:

答案 0 :(得分:1)

试试这个:

CGRect frame = Guy.frame;
[UIView animateWithDuration:0.6 delay: 0 options:UIViewAnimationCurveEaseInOut  animations: ^{
    Guy.frame = CGRectMake(frame.origin.x, frame.origin.y - 7,
                           frame.size.width, frame.size.height);
} completion: ^(BOOL finished) {
    if (finished) {
        [UIView animateWithDuration:0.6 delay: 0 options:UIViewAnimationCurveEaseInOut  animations: ^{
            Guy.frame = CGRectMake(frame.origin.x, frame.origin.y + 7,
                                   frame.size.width, frame.size.height);
        }];
    }
}];

答案 1 :(得分:0)

[UIView animateWithDuration:1.0
    delay: 0.0
    animations:^{
         image.frame = CGRectMake(image.frame.origin.x, image.frame.origin.y-7, image.frame.size.width, image.frame.size.height);
    }
    completion:^(BOOL finished){
        // move it ba
        [UIView animateWithDuration:1.0
             delay: 1.0
             options:UIViewAnimationOptionCurveEaseOut
             animations:^{
                image.frame = CGRectMake(image.frame.origin.x, image.frame.origin.y+7, image.frame.size.width, image.frame.size.height);
             }
             completion:nil];
    }];

答案 2 :(得分:0)

[UIView animateWithDuration:.5 delay:0.0
                    options:UIViewAnimationOptionCurveEaseIn
                 animations:^{
                     CGRect f = imageview.frame;
                     f.origin.y -= 40;
                     imageview.frame = f;
                 }
                 completion:nil];
if (imageview.frame.origin.y) {

 [UIView animateWithDuration:.6 delay:0.1
                                         options:UIViewAnimationOptionCurveEaseIn
                                      animations:^{
                                          CGRect f = imageview.frame;
                                          f.origin.y += 80;
                                          imageview.frame = f;
                                      }
                  completion:nil];}