Home > OS >  Modal presentation Controller with transparent background
Modal presentation Controller with transparent background

Time:06-01

how to remove the default gray colour when change detent in modal presentation from medium to large ? enter image description here

I need to remove this gray colour attached in above image while drag page sheet or move it I need to make it Transparent colour while moving modal to be like this when move from medium detent to large one

enter image description here

CodePudding user response:

You should have to set the view background color to be clear before presenting the modal

self.view.backgroundColor = .clear
self.modalPresentationStyle = .currentContext
self.present(nextVC, animated: true, completion: nil)

CodePudding user response:

If you are using UISheetPresentationController to present. You can look at largestUndimmedDetentIdentifier.

If you set that variable to .large your medium detent will have no dimmed background.

if let sheet = vc.sheetPresentationController {
    sheet.detents = [.medium(), .large()]
    sheet.prefersGrabberVisible = true
    sheet.selectedDetentIdentifier = .medium
    sheet.prefersScrollingExpandsWhenScrolledToEdge = false
    sheet.prefersEdgeAttachedInCompactHeight = true
    sheet.largestUndimmedDetentIdentifier = .large
}
  • Related