I'm using the UISheetPresentationController to present a view, as shown in the following code:
@IBAction func click(_ sender: Any) {
let whiteViewController = WhiteViewController.instanceFromMainStoryBoard()
if let sheet = whiteViewController.sheetPresentationController {
sheet.detents = [.medium()]
sheet.prefersScrollingExpandsWhenScrolledToEdge = false
sheet.prefersGrabberVisible = false
// Remove dim effect.
////sheet.largestUndimmedDetentIdentifier = .medium
}
self.present(whiteViewController, animated: true)
}
The outcome is as follow
This code results in a presentation with:
- A dimmed background.
- A 'Touch anywhere to dismiss' behavior.
However, I want to remove the dim background while keeping the 'Touch anywhere to dismiss' functionality. When I add the line:
sheet.largestUndimmedDetentIdentifier = .medium
The dim background is indeed removed, but the touch-to-dismiss behavior is gone too, as illustrated:
Is there a way to achieve both – removing the dim background and retaining the touch-to-dismiss functionality?
Thank you.