UIView animateWith Duration 사용 설명
2213 단어 animation
UIView animateWith Duration 사용 설명
에 발표 하 다 2012 년 3 월 4 일
ios 4.0 및 이후 애니메이션 효 과 를 실현 하기 위해 animateWith Duration 방법 을 사용 하도록 권장 합 니 다.물론 기 존의 begin/commit 방법 은 여전히 사용 되 고 있 으 며,animate With Duration 의 사용 방법 에 대해 자세히 설명 하 겠 습 니 다.
함수 원형:
+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations
+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion
+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion
그 중
4.567917.duration 은 애니메이션 이 지속 되 는 시간 입 니 다
다음은 애니메이션 효 과 를 설정 할 수 있 는 속성 입 니 다.
예 를 들 어 하나의 보기 페이드아웃 화면,다른 보기 에 나타 난 코드:
[UIView animateWithDuration:1.0 animations:^{
firstView.alpha = 0.0;
secondView.alpha = 1.0;
}];
delay 는 애니메이션 이 시작 되 기 전에 기다 리 는 시간 입 니 다
[UIView animateWithDuration:2.0
animations:^{
oldImageView.alpha = 0.0;
newImageView.alpha = 1.0;
//imageView.center = CGPointMake(500.0, 512.0);
}
completion:^(BOOL finished){
[UIView animateWithDuration:4.0
animations:^{
newImageView.center = CGPointMake(500.0, 512.0);
}];
}];
구체 적 인 효 과 는 한 폭 의 그림 이 점점 사라 지고 다른 한 폭 의 그림 이 나타 난 후에 그림 의 위치 가 이동 하 는 것 이다.