Reputation: 3246
I have a View Controller in which it presents another view controller, modally (bottom-top animation).
I'm trying to present the View Controller, with a specific size, I want it to be presented modally , but in this case to be 80% of it's native size.
let newVC = tabBarController.storyboard?.instantiateViewController(withIdentifier: "newPostVC") as? NewPostVC
newVC.view.frame = CGRect(x: 0, y: 0, width: tabBarController.view.frame.width, height: tabBarController.view.frame.height * 0.8)
tabBarController.present(newVC, animated: true)
But the view controller gets presented in its full size (screen size). I think that I've to twerk the view controller's size, but I might be wrong.
My view controller in the storyboard has it's Transitional Style set to: Cover Vertical and the Presentation is set to: Full Screen.
Could this be the issue?
Can you give me a hint?
Thanks :)
Upvotes: 1
Views: 1354
Reputation: 1884
Try doing something like this.
Create a ContainerVC
programmatically add newVC
as a subView . In the ContainerVC viewDidLoad()
newVC
to be 80%
of the container size. You can use some framework like Anchorage
to easily set this constraints. backgroundColor = .clear
.overCurrentContext
like this modalPresentationStyle = .overCurrentContext
While presenting it you can something like this
//create view controller
let VC = ContainerVC()
//present modal
self.present(VC, animated: true, completion: nil)
Upvotes: 1