Showing pushviewcontroller animation look like presentModalViewController

半腔热情 提交于 2019-11-27 02:46:23
jithinroy

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

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

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.

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));

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!