martinnormark / HalfModalPresentationController

Modal presentation that takes up half the screen. Swipe down to dismiss.
http://martinnormark.com/presenting-ios-view-controller-as-bottom-half-modal/
MIT License
472 stars 66 forks source link

Prevent fullscreen #19

Open UtkuDalmaz opened 6 years ago

UtkuDalmaz commented 6 years ago

Hi there

How can I prevent modal viewcontroller to be fullscreen?

podratz commented 5 years ago

You can achieve this by cancelling the pan when the drag offset becomes negative.

class HalfModalPresentationController: UIPresentationController {

    // ...

    func onPan(pan: UIPanGestureRecognizer) -> Void {
        let endPoint = pan.translation(in: pan.view?.superview)

        guard endPoint.y > 0 else {
            return pan.state = .cancelled
        }

        // ...

    }

    // ...

}