Search code examples
swiftviewpopupheightviewcontroller

Height of view as a modal popup - Swift


In the app that I am creating with XCode I created a view that opens as a modal popup. I used this code:

@IBAction func open_view(_ sender: Any) {
    let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
    let VC_test_object = storyBoard.instantiateViewController(withIdentifier: "VC_Test")
    VC_test_object.modalPresentationStyle = .popover;
    self.present(VC_test_object, animated: true, completion: nil)
}

VC_Test is the ViewController in Storyboard. This is the result:

View

However, I would like to manage the height of the view to create a sort of menu. As in this example screenshot (from the Documents app):

Example

I can't understand how to do it.

Could you tell me how to manage the height of the popup?

Thanks for your help.


Solution

  • For a code-your-self version this SO link and the answers below it is what you need: Present modal view controller in half size parent controller

    However, I would rather use this third party library : Presentr