简体   繁体   中英

click on UIbutton then open new UIviewController in top to down like pull down

(IBAction)btnClick:(id)sender
{
    secondView *sc= [self.storyboard instantiateViewControllerWithIdentifier:@"secondView"];
    [self.navigationController pushViewController:sc animated:YES];
}

You should achieve different navigation style using below code, Hope this will be help for you.

UIViewController * secondView = [self.storyboard instantiateViewControllerWithIdentifier:@"secondView"];


CATransition* transition = [CATransition animation];
transition.duration = 0.5;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFade; //kCATransitionMoveIn; //, kCATransitionPush, kCATransitionReveal, kCATransitionFade
//transition.subtype = kCATransitionFromTop; //kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom

[self.navigationController.view.layer addAnimation:transition forKey:nil];
[self.navigationController pushViewController:secondView animated:NO];

Happy Coding!

For View Animation:

For animation from Bottom to Top add below

[UIView animateWithDuration:0.5
                      delay:0.1
                    options: UIViewAnimationCurveEaseIn
                 animations:^{
                     self.postStatusView.frame = CGRectMake(0, 0, 320, 460);
                 } 
                 completion:^(BOOL finished){
                 }];
[self.view addSubview:self.postStatusView];

try with like this

 UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
DetailViewController *eventDetailsViewController = [storyboard instantiateViewControllerWithIdentifier:@"DetailViewController"];

eventDetailsViewController.view.frame= CGRectMake(0, -self.view.bounds.size.height, self.view.bounds.size.width, self.view.bounds.size.height);
eventDetailsViewController.view.backgroundColor = [UIColor redColor];

[UIView animateWithDuration:1.5 delay:0.f options:UIViewAnimationOptionCurveEaseInOut animations:^{
    [eventDetailsViewController.view setFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
} completion:^(BOOL finished){

}];

[self.view addSubview:eventDetailsViewController.view];
[self addChildViewController:eventDetailsViewController];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM