본문 바로가기
프로그래밍/iOS

uiview trasition(UIView 좌우 슬라이드)

by 백룡화검 2011. 6. 24.
배너를 우에서 좌로 밀어내듯이 롤링 시키는 효과를 줘야하는 작업이 생겼다
구글신을 찾던 도중에 아래와 같은 방법을 찾았다.
실제 해보지는 않았지만 소스만 봐서는 그럴듯 해 보인다.

나중에 해봐야지...

방법 1.
[
UIView beginAnimations:nil context:nil];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:view1.view cache:YES];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:view2.view cache:YES];
[UIView setAnimationDuration: 1.5];
[UIView commitAnimations];

view1
.view.hidden = YES;
view2
.view.hidden = NO;

방법 2.
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];
[view1 viewWillDisappear:YES];
[view2 viewWillAppear:YES];

view1
.view.hidden = YES;
view2
.view.hidden = NO;
[view1 viewDidDisappear:YES];
[view2 viewDidAppear:YES];
[UIView commitAnimations];


방법 3.
[UIView animateWithDuration:0.5
                  delay
:0.0
                options
:UIViewAnimationOptionTransitionFlipFromRight
             animations
:^{
                             
[view1 removeFromSuperview];
                             
[mySuperview addSubview:view2];
                         
};
             completion
:NULL];

출처 : http://stackoverflow.com/questions/4368491/uiview-transition-inside-uiview