HalfModalPresentationController icon indicating copy to clipboard operation
HalfModalPresentationController copied to clipboard

Prevent fullscreen

Open UtkuDalmaz opened this issue 6 years ago • 1 comments

Hi there

How can I prevent modal viewcontroller to be fullscreen?

UtkuDalmaz avatar Oct 04 '18 12:10 UtkuDalmaz

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
        }
        
        // ...
   
    }

    // ...

}

podratz avatar Dec 23 '18 10:12 podratz