创建自定义视图控制器动画
Posted
技术标签:
【中文标题】创建自定义视图控制器动画【英文标题】:Creating a custom View Controller Animation 【发布时间】:2014-02-20 05:12:30 【问题描述】:我正在尝试创建一个视图控制器动画,其中用户当前在屏幕上的视图控制器向下滑动,在下面显示新的视图控制器。所以新的视图控制器会像背景一样,新的视图控制器会向下滑动并显示它。我试了一下,但没有成功。你会如何建议这样做?
这是我尝试过的:
-(void)showLogout:(UIButton *)sender
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"TermsAccepted"];
WelcomeViewController *welcomeViewController = [[WelcomeViewController alloc] init];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
self.view.frame = CGRectMake(0, 1200, 320, 568);
[self.navigationController pushViewController:welcomeViewController animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.view cache:YES];
[UIView commitAnimations];
【问题讨论】:
【参考方案1】:试试这个
-(void)showLogout:(UIButton *)sender
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"TermsAccepted"];
WelcomeViewController *welcomeViewController = [[WelcomeViewController alloc] init];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController cache:YES];
self.view.frame = CGRectMake(0, 1200, 320, 568);
[self.navigationController pushViewController:welcomeViewController animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.view cache:YES];
[UIView commitAnimations];
【讨论】:
以上是关于创建自定义视图控制器动画的主要内容,如果未能解决你的问题,请参考以下文章