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)