2014-04-13 5 views
-3

내 이미지가 7 축의 선이나 다른 점으로 점프되기를 바란다. 그러나 나는 그가 뒤로 넘어 지길 바란다. 어떤 도움?어쨌든 나는 내 이미지 점프를 다시 떨어 뜨릴 수있다.

Heres는 내 코드 :

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]; 
+2

. 이에 대해 알지 못하면 WWDC 2013 ("UIKit Dynamics 시작하기")에서 비디오를 볼 것입니다. – rdelmar

+0

@rdelmar의 좋은 점 ... 그의 코멘트에 덧붙여서 나는 같은 글을 지적하고 싶다 .. http://www.teehanlax.com/blog/introduction-to-uikit-dynamics/ – GenieWanted

답변

1

이 시도 : 당신은이 작업을 수행 UIDynamicAnimator 및 관련 클래스로 보일 것입니다

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); 
     }]; 
    } 
}]; 
+2

당신의 유권자는 이유를 설명 할 예의없는 사람이었습니다. 귀하의 코드는 질문에 대답하지 않습니다. 이 질문은 어떻게 이미지를 움직이게 한 다음 다시 내려야하는지 묻습니다. – rmaddy

+1

더 좋은 모습을 내기 위해 각 방향의 애니메이션 커브를 지정하고 싶을 수도 있지만 더 좋아 보인다. – rmaddy

+0

didnt work ....... – MinecraftSyntax

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]; 
    }]; 
+0

두 번째 애니메이션이이 질문에 부적절한 것 같습니다. – rmaddy

+0

죄송합니다! – phantomhive

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];}