Prevent background view from being resized when using iOS 13+ default modal presentation

This simple trick helps preventing the system from resizing the background view when the modal appears. It keeps the standard behavior (panning view, partial view with dark veil) but leave the background view untouched.

Simply set the following flag on your UIViewController, for instance inside the viewDidLoad method:

definesPresentationContext = true

If the presenting view controller is a child of a navigation controller, then we need to apply this flag to the navigationController instead of self:

navigationController?.definesPresentationContext = true


Leave a Reply

Your email address will not be published. Required fields are marked *