Using drawer effects in Swift projects based on MMDrawerController

Source: Internet
Author: User

Using drawer effects in Swift projects based on MMDrawerController

// AppDelegate.swiftvar drawer = MMDrawerController()
Let leftViewController = LeftViewController () let rightViewController = RightViewController () let centerViewController = ViewController () let centerNav = UINavigationController. init (rootViewController: centerViewController) // set the Left and Right controllers to drawer = MMDrawerController. init (centerViewController: centerNav, leftDrawerViewController: leftViewController, rightDrawerViewController: rightViewController) // side distance Leave drawer. maximumLeftDrawerWidth = 0.7 * width drawer. maximumRightDrawerWidth = 0.7 * width // gesture drawer. openDrawerGestureModeMask = MMOpenDrawerGestureMode. all drawer. closeDrawerGestureModeMask = MMCloseDrawerGestureMode. all // set the animation. The transparency of the opening sidebar is set from 0 to 1 drawer. setDrawerVisualStateBlock {(drawerController, drawerSide, percentVisible)-> Void in var sideDrawerViewController: UIViewController? If (drawerSide = MMDrawerSide. Left) {sideDrawerViewController = drawerController. Rows;} if (drawerSide = MMDrawerSide. Left) {rows = drawerController. rightDrawerViewController;} sideDrawerViewController ?. View. alpha = percentVisible} self. window ?. RootViewController = drawer
In the method of clicking tableview in the left-side VC
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {        switch (indexPath.row){        case 0:            let centerViewController = ViewController()            let centerNavigationController = UINavigationController(rootViewController: centerViewController)            let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate            appDelegate.drawer.centerViewController = centerNavigationController            appDelegate.drawer.toggleDrawerSide(MMDrawerSide.Left, animated: true, completion: nil)        default:            let otherViewController = TestViewController()            let otherNavigationController = UINavigationController(rootViewController: otherViewController)            let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate            appDelegate.drawer.centerViewController = otherNavigationController            appDelegate.drawer.toggleDrawerSide(MMDrawerSide.Left, animated: true, completion: nil)        }    }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.