apparition47 / Sheetable

Transition any UIViewController as a bottom sheet

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sheetable

Present any UIViewController as a bottom sheet modal with interactive dismissal.

Originally based on HalfModalPresentationController.

Demo

How to use

  1. Conform the UIViewController you want to present as a bottom sheet modal to Sheetable. [Optional] Override height 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
}
  1. Before presenting your UIViewController from the nav stack, call setTransitioningDelegate().
class HomeViewController: UIViewController {
    @IBAction func showModalButtonPressed(_ sender: Any) {
        let vc = DetailViewController()
        vc.setTransitioningDelegate() // <--
        navigationController.present(vc, animated: true)
    }
}

License

MIT

About

Transition any UIViewController as a bottom sheet

License:MIT License


Languages

Language:Swift 100.0%