Que20 / UIDrawer

A drawer that mimics the bottom sheet from the Maps app.
MIT License
85 stars 16 forks source link
ios swift uikit

UIDrawer

UIDrawer is a customizable UIPresentationController that allows modals to be presented like a bottom sheet. The kind of presentation style you can see on the Maps app on iOS.

It supports :

Screenshot

Demo screenshot

Installation

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate Alamofire into your Xcode project using Carthage, specify it in your Cartfile:

github "Que20/UIDrawer" ~> 1.0

CocoaPod

CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate Alamofire into your Xcode project using CocoaPods, specify it in your Podfile:

platform :ios, '12.0'
target 'YourTarget' do
    use_frameworks!
    pod 'UIDrawer', :git => 'https://github.com/Que20/UIDrawer.git', :tag => '1.0'
end

Usage

Present your drawer like a normal modal with a presentation style set as custom and set a transition delegate :

let viewController = MyViewController()
viewController.modalPresentationStyle = .custom
viewController.transitioningDelegate = self
self.present(viewController, animated: true)

To your transitionDelegate, implement the presentationController func, and return a DrawerPresentationController.

extension ViewController: UIViewControllerTransitioningDelegate {
    func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? {
        return DrawerPresentationController(presentedViewController: presented, presenting: presenting)
    }
}

Here ViewController is the controller that presents the drawer.

Customization

You can customize the DrawerPresentationController by setting :

Evolutions

A quick todo list for features I want to implement in the futur :

Contribute

Please ;)