뷰 애니메이션 전환
3377 단어 view
#import "MainViewController.h"
@interface MainViewController ()
@end
@implementation MainViewController
- (void)viewDidLoad
{
[super viewDidLoad];
UIView *view1 = [[UIView alloc]initWithFrame:[[UIScreen mainScreen] bounds]];
view1.backgroundColor = [UIColor blueColor];
UIView *view2 = [[UIView alloc]initWithFrame:[[UIScreen mainScreen] bounds]];
view2.backgroundColor = [UIColor yellowColor];
[self.view addSubview:view1];
[self.view addSubview:view2];
}
-(void) changeView
{
NSLog(@"change view");
CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition: UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];
[self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:nil];
[UIView commitAnimations];
}
-(void) changeView2
{
CATransition *animation = [CATransition animation];
[animation setDuration:1.25f];
[animation setTimingFunction:[CAMediaTimingFunction
functionWithName:kCAMediaTimingFunctionEaseIn]];
[animation setType:kCATransitionReveal];
[animation setSubtype: kCATransitionFromRight];
[self.view.layer addAnimation:animation forKey:@"Reveal"];
[self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
[CATransaction commit];
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[self changeView];
}
@end
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Getting Started with Zend Framework 2 - ViewBy default, the action and view in the controller are one-to-one correspondence, such as HellowordController::indexActio...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.