Drawer like Google material design for iOS

Toshi picture Toshi · Aug 11, 2015 · Viewed 25.9k times · Source

I'd like to implement navigation drawer like Uber into iOS(swift). I'm going to achieve it by using a library, called KYDrawerController. https://github.com/ykyouhei/KYDrawerController

However, it cannot provide toggle button, only slide action. Thought I'd like to to implement toggle button that shows the navigation drawer,I have no idea how to add such a function to the library. If you know how to add the function to the library, or how to achieve my purpose the other way(such as to use the other libraries), please tell me. Thank you for your kindness.

Uber1 Uber2

Answer

Kyouhei Yamaguchi picture Kyouhei Yamaguchi · Aug 15, 2015

Using KYDrawerController it can be implemented as follows:

class MainViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        view.backgroundColor = UIColor.whiteColor()
        title = "MainViewController"
        navigationItem.leftBarButtonItem = UIBarButtonItem(
            title: "Open",
            style: UIBarButtonItemStyle.Plain,
            target: self,
            action: "didTapOpenButton:"
        )
    }

    func didTapOpenButton(sender: UIBarButtonItem) {
        if let drawerController = navigationController?.parentViewController as? KYDrawerController {
            drawerController.setDrawerState(.Opened, animated: true)
        }
    }
}

https://github.com/ykyouhei/KYDrawerController/tree/master/Example/Code