Present any UIViewController as a bottom sheet modal with interactive dismissal.
Originally based on HalfModalPresentationController.
- Conform the
UIViewControlleryou want to present as a bottom sheet modal toSheetable. [Optional] Overrideheightto how much of the screen you want your view to take up from the bottom.
class DetailViewController: UIViewController {}
extension DetailViewController: Sheetable { // <--
var height: CGFloat { return 400 } // optional
}- Before presenting your
UIViewControllerfrom the nav stack, callsetTransitioningDelegate().
class HomeViewController: UIViewController {
@IBAction func showModalButtonPressed(_ sender: Any) {
let vc = DetailViewController()
vc.setTransitioningDelegate() // <--
navigationController.present(vc, animated: true)
}
}MIT
