Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to present a UIViewController from top to bottom in iOS?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.52k
    Comment on it

    When we present the viewcontroller it slides from bottom to top but, if we want to change the slide position then we have to use the animation for the UIView. By using animation we just change the frames of UIView.

     If we want to present the controller from top to bottom then use the below function-

     

    -(void)presentControllerFromTopToBottom{
    
        YourViewController *yourVC=[self.storyboard instantiateViewControllerWithIdentifier:@"StoryboardID"];
    
        [self.view addSubview:yourVC.view];
        yourVC.view.tag = 1001;
        yourVC.view.frame=CGRectMake(0,-self.view.frame.size.height,self.view.frame.size.width,self.view.frame.size.height);
        
        [UIView animateWithDuration:0.5
                         animations:^{
                             yourVC.view.frame=CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height);
                         }
                         completion:^(BOOL fin){
                             if (fin)
                             {
                                 [yourVC.view removeFromSuperview];
    
                                 [self performSegueWithIdentifier:@"yourVC" sender:nil];
                             }
                         }];
    }
    
    
    
    

    Call the above function where you want to present YourViewController.

    Also, Uncheck the animates option when you perform segue using storyboard.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: