创建自定义视图控制器动画

时间:2014-02-20 05:12:30

标签: ios animation uiviewcontroller

我正在尝试创建一个视图控制器动画,其中用户当前正在向下滑动的视图控制器和屏幕,显示新的视图控制器。因此,新的视图控制器将像背景一样,新的视图控制器向下滑动并显示它。我已经试了一下,但没有取得任何成功。你会怎么推荐这样做?

以下是我的尝试:

-(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 个答案:

答案 0 :(得分:0)

试试这个

-(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];