10

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

Alexander Graebe
  • 797
  • 5
  • 10
Toshi
  • 1,293
  • 3
  • 19
  • 37
  • what toggle button, are you referring to the button that shows the navigation drawer – meda Aug 10 '15 at 23:11
  • Yes. The button that shows the drawer – Toshi Aug 10 '15 at 23:13
  • so why not adding a UIBarbutton that will call the slide action, never used that library. I have used this one https://github.com/ECSlidingViewController/ECSlidingViewController and it can do what your looking for – meda Aug 10 '15 at 23:15
  • 1
    In general you'll notice Apple themselves never use a drawer (aka hamburger menu) UI. (Perhaps someone can find a example?) As a thought experiement, you might try to imagine a tab bar-based interface that provides the same features. – nielsbot Aug 10 '15 at 23:18
  • Sorry, I didn't explain enough. I want to make drawer menu slide over the main view, not push the main view. I've achieve the latter view by MMDrawerController https://github.com/mutualmobile/MMDrawerController, but I'd like to change it. – Toshi Aug 10 '15 at 23:21
  • follow up: I saw this linked on hacker news today: http://deep.design/the-hamburger-menu/ – nielsbot Aug 11 '15 at 04:06
  • haha, it criticizes a hamburger menu. Thank you for your advice:) – Toshi Aug 11 '15 at 04:23

1 Answers1

15

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

pkamb
  • 33,281
  • 23
  • 160
  • 191
  • Thank you! In fact, I've found your library then solved the problem. lol Very good library:) – Toshi Aug 16 '15 at 05:31