I have ViewController
and when user clicks at a bottom of it then other ViewController
pops-up using segue Present Modally
.
Is it possible to give custom size to them ? I tried giving Content Size by Use Preferred Explicit Size
option but it didn't help. I want that VC to pop up and take 70% of the current VC from up.
How to set Custom size to Present Modally ViewController
4k Views Asked by Nitesh AtThere are 3 best solutions below

You should add a view of 70 % of size on your second VC
(I mean which you are presenting), and set background color of that VC's view
as clear color
so for that remaining 30 % will display previous VC.
For example your VC's height is 100 px then add another view
with height of 70 pixel
and set clear background color
to self.view
I mean main view of VC!
Now set modalPresentationStyle
to your VC before presenting it like,
yourVC.modalPresentationStyle = UIModalPresentationOverCurrentContext;
[self presentViewController:yourVC animated:YES completion:^{
}];
If you are giving support lesser than ios 8
then you need to set setModalPresentationStyle
to NavigationController(If you are using else parent view controller - which are presenting view controller)
like,
[self.navigationController setModalPresentationStyle:UIModalPresentationCurrentContext];
[self presentViewController:yourVC animated:YES completion:^{
}];
Swift :
yourVC.modalPresentationStyle = UIModalPresentationStyle.OverCurrentContext
self.presentViewController(yourVC, animated: true) {
}
or
self.navigationController?.modalPresentationStyle = UIModalPresentationStyle.CurrentContext
self.presentViewController(yourVC, animated: true) {
}

Have a look into this and let me know if you want any clarification.
__weak IBOutlet UIView *conViewers;
- (void)callingOfCustomView:(UIViewController *)showPushedVC
{
[showPushedVC.view setTranslatesAutoresizingMaskIntoConstraints:YES];
showPushedVC.view.frame = conViewers.bounds;
//**>> Add child view into container view
[conViewers addSubview: showPushedVC.view];
[self addChildViewController: showPushedVC];
[showPushedVC didMoveToParentViewController:self];
}
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
ViewersVC *objViewers = [storyboard instantiateViewControllerWithIdentifier:@"ViewersVC"];
[self callingOfCustomView:objViewers];
Will update this in swift.
Solved it by using
UIContainerView
instead of "Present Modally" segue.This is how I did it in case anyone else is struggling with same issue.
DO NOT SET ANY SEGUE/EMBED TO VC B/W
UIContainerView
. Add STORYBOARD ID.THEN WHENEVER YOU WANT TO CHANGE VIEW ACCORDING TO ACTION