2013-07-03 2 views
1

다음을 사용하여 UIImageView 슬라이드를 약간 앞으로 만들고 시차 스크롤 효과를 위해 뒤로 멀리 슬라이드합니다.UIImageView 애니메이션에 약간의 완화 적용하기

코드 : 그냥 갑자기 앞뒤로 빠르게 슬라이드 만약 내가 지금, 애니메이션으로 일부 완화 적용에 대해 갈 수있는 방법을

[UIView animateWithDuration:0.2f animations:^{ 
    spendrBckGrnd.frame = CGRectMake(spendrBckGrnd.frame.origin.x + 20, 0, spendrBckGrnd.frame.size.width, spendrBckGrnd.frame.size.height); 
}]; 
[UIView animateWithDuration:0.4f animations:^{ 
    spendrBckGrnd.frame = CGRectMake(spendrBckGrnd.frame.origin.x - 80, 0, spendrBckGrnd.frame.size.width, spendrBckGrnd.frame.size.height); 
}]; 

을 궁금해하고있다. 슬라이딩 애니메이션을 들락날락하고 싶습니다.

답변

0

당신은 첫 번째가 완료 후 두 번째 애니메이션 블록 을 할 필요가있다.

[UIView animateWithDuration:0.2f animations:^{ 
    spendrBckGrnd.frame = CGRectMake(spendrBckGrnd.frame.origin.x + 20, 0, spendrBckGrnd.frame.size.width, spendrBckGrnd.frame.size.height); 
} completion:^{ 
    [UIView animateWithDuration:0.2f animations:^(BOOL finished){ 
     spendrBckGrnd.frame = CGRectMake(spendrBckGrnd.frame.origin.x - 80, 0, spendrBckGrnd.frame.size.width, spendrBckGrnd.frame.size.height); 
    }]; 
}]; 
+0

그건 그게, 내가 UIView에서 그 다른 정적 메서드를 잡았 믿을 수 없어. BTW, 당신의 코드는 필요한 것처럼 작동하지만 두 번째 블록에 (BOOL 완료)를 추가해야합니다. –

+0

맞습니다. 감사. 그것을 수정했습니다. –

0

체크 아웃의 UIView는 메소드가 http://mobile.tutsplus.com/tutorials/iphone/ios-sdk_uiview-animations/

UIView의 애니메이션에서이 가이드

또한
// [UIView animateWithDuration:(NSTimeInterval) delay:(NSTimeInterval) options:(UIViewAnimationOptions)animations:^(void)animations completion:^(BOOL finished)completion]; 
typedef enum { 
     UIViewAnimationCurveEaseInOut,   // slow at beginning and end 
     UIViewAnimationCurveEaseIn,   // slow at beginning 
     UIViewAnimationCurveEaseOut,   // slow at end 
     UIViewAnimationCurveLinear 
    } 
    [UIView animateWithDuration:0.6f 
       delay:0.1f 
       options:UIViewAnimationCurveEaseInOut 
       animations:^{ 
         [starView setCenter:CGPointMake(0, 0)]; 
         [starView setAlpha:0.0f]; 
       } 
       completion:^(BOOL finished){ 
          [starView removeFromSuperview]; 
          points++; 
       } 
    ]; 

훨씬 위쪽 같이 정의 컨테이너 뷰를 사용하여 시차 효과를 생성 GitHub의에이 제어 확인 경로의 타임 라인보기. https://github.com/modocache/MDCParallaxView

0

이 은 트릭을 할 것입니다 :

[UIView animateWithDuration:0.2f delay:0 options:UIViewAnimationOptionCurveEaseInOut  animations:^(void){ 
//do your animations 
} completion:^(BOOL finished){ 

}];