Q: Popover to cover bottom half of the screen I am trying to implement a popover that covers the bottom half of the screen. For some reason though, it's not calculating the width and height of the popover correctly.
This is my code:
let storyboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "CommentsViewController") as! CommentsViewController
vc.modalPresentationStyle = .popover
vc.preferredContentSize = CGSize(width: self.view.frame.width, height: self.view.frame.height/2)
            
let popover: UIPopoverPresentationController = vc.popoverPresentationController!
popover.delegate = self
popover.permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0)
popover.sourceView = self.view
popover.sourceRect = CGRect(x: 0, y: self.view.bounds.midY, width: self.view.frame.width, height: self.view.frame.height/2)
                    
self.present(vc, animated: true, completion:nil)

This is what it showing up as currently (the popover is the purple rectangle):

I want it look like:

How do I get the popover to cover the bottom half of the screen?
