抽屉像谷歌的iOS材料设计

抽屉像谷歌的iOS材料设计

本文介绍了抽屉像谷歌的iOS材料设计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

解决方案

使用它可以实现如下:

  class MainViewController:UIViewController {

override func viewDidLoad(){
super.viewDidLoad()

//加载视图后进行任何其他设置。
view.backgroundColor = UIColor.whiteColor()
title =MainViewController
navigationItem.leftBarButtonItem = UIBarButtonItem(
title:Open,
style:UIBarButtonItemStyle。普通,
目标:self,
操作:didTapOpenButton:

}

func didTapOpenButton(发件人:UIBarButtonItem){
如果让drawerController = navigationController?.parentViewController为? KYDrawerController {
drawerController.setDrawerState(.Opened,animated:true)
}
}
}


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.

解决方案

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

这篇关于抽屉像谷歌的iOS材料设计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 21:19