0

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.

dimadev
  • 23
  • 1
  • 1
  • 6

1 Answers1

0

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

Mohammad Assad Arshad
  • 1,535
  • 12
  • 14
  • Hello and thanks for the reply. I did some tests. The first answer doesn't work. The second covers the contents of the view created in interface builder. The third works well, but I had to make some changes. I had to add a 50% black background in the main view and I had to enter a notification to remove the background when the second view is closed. But in this way I cannot manage the tap on the background to close the second view. I haven't solved 100%, but it's already something ... – dimadev Jun 09 '20 at 20:58
  • Hey. As far as I understand, you should be able to use `PresentationType.bottomHalf` to do what you need and without the need of having 50% black background. You can see it the example in the Gif below: https://camo.githubusercontent.com/aca4ccf8f2b72cf20fa70d9c9b32eb88c5be304f/687474703a2f2f64616e69656c6f7a616e6f2e636f6d2f50726573656e74722f476966732f426f74746f6d48616c66536c6f772e676966 But since I dunno your exact use case, so not sure how relevant it is. Anyway good luck for the app ! – Mohammad Assad Arshad Jun 10 '20 at 01:41
  • 1
    Hi. I have not used Presentr. So I can't use PresentationType.bottomHalf. It doesn't matter, I still solved it in a strange way :) Thx for your help :) – dimadev Jun 11 '20 at 07:08