2013-10-26 6 views
0

단순히 화면에 뷰를 이동하려면 UIView 애니메이션을 사용하는 것을 시도하고있다 :UIView의 애니메이션 : 시뮬레이션 속도

[UIView animateWithDuration:.10 delay:0 options: nil animations:^ 
    { 
     self.menusView.frame = endingMenuViewFrame;; 
    } 
    completion:^(BOOL finished) 
    { 

    }]; 

내가 UIView의 조금 떠 있도록이 도달 할 때 애니메이션을 추가 꿔 그것이 내려 오기 전에 가기, 즉 누군가가 공중에서 점프하는 것과 비슷합니다. 처음으로 뛰어 내릴 때, 그들은 빨리 뛰어 오르지 만 중력은 점프의 최상위에 도달 할 때 점차 속도를 늦추고, 결국에는 다시 땅으로 밀어냅니다 . 아무도 이것을 수행하는 방법을 알고 있습니까?

답변

2

이 코드를 사용해보십시오. 이렇게하면 높이가 반으로 줄어들 때마다 세 번 바운스됩니다. 더 많은 반송을 추가 할 수 있습니다.

CGFloat offset = 200.0; 

CGRect originalFrame = self.menusView.frame; 

[UIView animateWithDuration:1.0 animations:^{ 
    CGRect frame = self.runnerAlertView.frame; 
    frame.origin.y = frame.origin.y - offset; 
    self.menusView.frame = frame; 
} completion:^(BOOL finished){ 
    [UIView animateWithDuration:1.0 animations:^{ 

     self.menusView.frame = originalFrame; 
    } completion:^(BOOL finished) { 
     [UIView animateWithDuration:1.0 animations:^{ 
      CGRect frame = self.menusView.frame; 
      frame.origin.y = frame.origin.y - 0.5 *offset; 
      self.menusView.frame = frame; 
     } completion:^(BOOL finished){ 
      [UIView animateWithDuration:1.0 animations:^{ 

       self.menusView.frame = originalFrame; 
      } completion:^(BOOL finished) { 
       [UIView animateWithDuration:1.0 animations:^{ 
        CGRect frame = self.runnerAlertView.frame; 
        frame.origin.y = frame.origin.y - 0.25 * offset; 
        self.menusView.frame = frame; 
       } completion:^(BOOL finished){ 
        [UIView animateWithDuration:1.0 animations:^{ 

         self.menusView.frame = originalFrame; 
        }]; 
      }]; 
     }]; 
     }]; 
    }]; 
}]; 
+0

+1. 고마워. UIViewAnimations를 둥지를 틀어서 사용하는 것과 같은 방식으로 사용하고 있습니다. 대신 핵심 애니메이션을 사용해야하는지 궁금합니다. –