Any way to change the amount of dimming when using a UISheetPresentationController?

94 Views Asked by At

I've been working with UISheetPresentationController lately and am wondering if it's possible to change the amount of dimming when using a UISheetPresentationController. Looking at the documentation, it looks like I can remove the dimming with largestUndimmedDetentIdentifier, but I don't see anything related to making it darker.

1

There are 1 best solutions below

0
teradyl On

Simplest way for now is to change the alpha of the presenting view controller in your bottom sheet being presented. Like so:

      override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        UIView.animate(withDuration: 0.4) {
          self.presentingViewController?.view.alpha = 0.6
        }
      }
      override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        UIView.animate(withDuration: 0.4) {
          self.presentingViewController?.view.alpha = 1
        }
      }

I hope later Apple will make this easier to do from the presenting side.