抽屉像谷歌的iOS材料设计

时间:2015-08-10 23:05:53

标签: ios material-design navigation-drawer drawertoggle

我想像Uber这样的导航抽屉实现iOS(swift)。我将通过使用名为KYDrawerController的库来实现它。 https://github.com/ykyouhei/KYDrawerController

但是,它不能提供切换按钮,只能滑动动作。以为我想实现显示导航抽屉的切换按钮,我不知道如何将这样的功能添加到库中。 如果您知道如何将函数添加到库中,或者如何以其他方式实现我的目的(例如使用其他库),请告诉我。 谢谢你的好意。

Uber1 Uber2

1 个答案:

答案 0 :(得分:12)

使用KYDrawerController可以按如下方式实施:

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

相关问题