Present any UIViewController as a bottom sheet modal with interactive dismissal.
Originally based on HalfModalPresentationController.
- Conform the
UIViewController
you want to present as a bottom sheet modal toSheetable
. [Optional] Overrideheight
to 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
UIViewController
from the nav stack, callsetTransitioningDelegate()
.
class HomeViewController: UIViewController {
@IBAction func showModalButtonPressed(_ sender: Any) {
let vc = DetailViewController()
vc.setTransitioningDelegate() // <--
navigationController.present(vc, animated: true)
}
}
MIT