Skip to content

Instantly share code, notes, and snippets.

@evarilci
Created May 20, 2024 08:16
Show Gist options
  • Select an option

  • Save evarilci/2b81a5a12aedc8965114069b245d379f to your computer and use it in GitHub Desktop.

Select an option

Save evarilci/2b81a5a12aedc8965114069b245d379f to your computer and use it in GitHub Desktop.
extension UIViewController {
func showBottomSheet(_ bottomSheet: UIViewController) {
if #available(iOS 16.0, *) {
if let sheetPresentationController = bottomSheet.presentationController as? UISheetPresentationController {
sheetPresentationController.detents = [.custom(resolver: {context in
250})]
sheetPresentationController.prefersGrabberVisible = true
}
} else {
if let sheetPresentationController = bottomSheet.presentationController as? UISheetPresentationController {
sheetPresentationController.detents = [.medium()]
sheetPresentationController.prefersGrabberVisible = true
}
}
present(bottomSheet, animated: true, completion: nil)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment