Swift MMDrawerController 抽屉的用法

 

 

 

 

 

 

 

 

在AppDelegate.h 中设置如下

 

import MMDrawerController

 

    var window: UIWindow?

    var drawer:MMDrawerController!

 

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

        

        

//        let mV = MainViewController()

        let lV = LeftViewController()

        let rV = RightViewController()

        let storyboard = UIStoryboard(name: "Main", bundle: Bundle.main)

        

 

    // 设置抽屉控制器 

        drawer = MMDrawerController(center: storyboard.instantiateViewController(withIdentifier: "main"), leftDrawerViewController: lV, rightDrawerViewController: rV)

        

        

        drawer.openDrawerGestureModeMask = .all

        drawer.closeDrawerGestureModeMask = .all

        

     //左右两边抽屉的宽度

        drawer.maximumLeftDrawerWidth = 300

        drawer.maximumRightDrawerWidth = 300

 

        self.window?.rootViewController = drawer

        self.window?.makeKeyAndVisible()

        return true

    }

 

 

//在MainViewController.h  中也要导入MMDrawerController。

 

    //左边按钮

    @IBAction func left(_ sender: UIButton) {

       self.mm_drawerController.toggle(MMDrawerSide.left, animated: true, completion: nil)

    }

    

 

    //右边按钮

    @IBAction func right(_ sender: UIButton) {

        self.mm_drawerController.toggle(MMDrawerSide.right, animated: true, completion: nil)

 

    }

转载于:https://www.cnblogs.com/chenxiaopao/p/7781034.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值