Showing pushviewcontroller animation look like presentModalViewController

后端 未结 5 768
时光说笑
时光说笑 2020-11-29 18:05

Is it possible to show pushViewController animation look like presentModalViewController but that has background functionality of pushViewCon

相关标签:
5条回答
  • 2020-11-29 18:07

    For display PushViewConttroler animation as Present below code is working,

    For Push

     ViewController *VC = [self.storyboard instantiateViewControllerWithIdentifier:@"ViewController"];
     CATransition* transition = [CATransition animation];
     transition.duration = 0.4f;
     transition.type = kCATransitionMoveIn;
     transition.subtype = kCATransitionFromTop;
     [self.navigationController.view.layer addAnimation:transition
                                                        forKey:kCATransition];
     [self.navigationController pushViewController:VC animated:NO];
    

    And for POP

    CATransition* transition = [CATransition animation];
    transition.duration = 0.4f;
    transition.type = kCATransitionReveal;
    transition.subtype = kCATransitionFromBottom;
    [self.navigationController.view.layer addAnimation:transition
                                                forKey:kCATransition];
    [self.navigationController popViewControllerAnimated:NO];
    

    There is 1 issue though, that its display light black background when its going up/down,
    Working on that, As soon as its done post new code here.

    0 讨论(0)
  • 2020-11-29 18:07

    You should consider doing something like:

    ViewController *myVC = [[ViewController alloc] initWithFrame:OFF_SCREEN];
    [navigationController pushViewController:myVC animated:NO];
    

    where OFF_SCREEN is some CGRect below the screen, like (0, 481, 320, 480). Then use an animation block to adjust the viewcontroller's view's frame.origin to be (0, 0). You would probably want to do the animate block in viewDidLoad or viewDidAppear.

    0 讨论(0)
  • 2020-11-29 18:09

    If you want to a fade animation, this approach works.

    CATransition* transition = [CATransition animation];
    transition.duration = 0.3;
    transition.type = kCATransitionFade;
    transition.subtype = kCATransitionFromTop;
    
    [self.navigationController.view.layer addAnimation:transition forKey:kCATransition];
    [self.navigationController pushViewController:gridController animated:NO];
    
    0 讨论(0)
  • 2020-11-29 18:12

    For All Trying in Xamarin (C#) equivalent Code From Answer by @hardik Thakkar above, Has the issue of Black backgound during animation, rest all good.

    For POP

        CATransition transition = CATransition.CreateAnimation();
        transition.Duration = 0.4;
        transition.Type = CAAnimation.TransitionReveal;
        transition.Subtype = CAAnimation.TransitionFromTop;
        this.NavigationController.View.Layer.AddAnimation(transition, nameof(CATransition));
    

    For Push

        CATransition transition = CATransition.CreateAnimation();
        transition.Duration = 0.4;
        transition.Type = CAAnimation.TransitionReveal;
        transition.Subtype = CAAnimation.TransitionFromBottom;
        this.NavigationController.View.Layer.AddAnimation(transition, nameof(CATransition));
    
    0 讨论(0)
  • 2020-11-29 18:26

    Try this :

    UIViewController *yourViewController = [[UIViewController alloc]init];
    
    [UIView  beginAnimations: @"Showinfo"context: nil];
    [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:0.75];
    [self.navigationController pushViewController: yourViewController animated:NO];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
    [UIView commitAnimations];
    
    0 讨论(0)
提交回复
热议问题