How can I slide my popover from the bottom of the screen with Swift?

1.1k Views Asked by At

I have a Main view controller that has a map. I have another controller that is being presented as a popover.

    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
        if segue.identifier == "weatherDetail" {

            let dest = segue.destination as! WeatherDetailController

            dest.json = json

            let screenSize: CGSize = UIScreen.main.bounds.size
            dest.preferredContentSize = CGSize(width: screenSize.width - 50, height: /*screenSize.height - 200*/ 153)

            let popoverController = dest.popoverPresentationController

            if popoverController != nil {
                popoverController?.delegate = self
                popoverController?.permittedArrowDirections = .init(rawValue: 0)
                popoverController?.sourceView = view
                popoverController?.sourceRect = CGRect(x: self.view.bounds.midX, y: self.view.bounds.size.height - (dest.preferredContentSize.height / 2) - 20, width: 0, height: 0)


            }
        }
    }

    func adaptivePresentationStyle(for controller:UIPresentationController) -> UIModalPresentationStyle {
        return .none
    }

Here is what the current code does (just to give an idea):

what happens now

I was wondering if instead of the popover appearing, could I have it slide in from the bottom? (I'm probably not using popovers correctly, it just seems to work for what I was doing).

0

There are 0 best solutions below