zoukankan      html  css  js  c++  java
  • MMDrawerController抽屉侧边栏的简单使用

    1.MMDrawerController是一个简单实用的侧边栏第三方类库。

    2.在appdelegate页中初始化你需要的左右侧边栏,leftViewController ,mainViewController。

    3.在appdelegate中导入头文件#import "MMDrawerController.h"

    4.初始化抽屉控制器: 
        MMDrawerController * drawerController = [[MMDrawerController alloc] initWithCenterViewController: mainViewControllerleftDrawerViewController:leftViewController];

       注:由于在MMDrawerController中机会没有涉及到storyboard的内容,如果想用xib来初始化该怎么办呢,方式如下:

             以main.storyboard为例:

              1.初始化:UIStoryboard* mainStoryboard = [UIStoryboard storyboardWithName:@"main" bundle: nil];

              2.添加到MMDrawerController中:drawerController = [[MMDrawerController alloc] initWithCenterViewController:[mainStoryboard instantiateViewControllerWithIdentifier:@"centerNav"] leftDrawerViewController:[mainStoryboard instantiateViewControllerWithIdentifier:@"menu"]];

    5.设置抽屉的一些属性

        //设置左抽屉抽出的宽度
        drawerController.maximumLeftDrawerWidth = 200;

       //设置抽屉视图VC阴影效果
            self.mmDrawController.showsShadow = YES;

    6.添加滑动手势,通过滑动手势拉出和收回抽屉。

        [drawerController setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeAll];
        [drawerController setCloseDrawerGestureModeMask:MMCloseDrawerGestureModeAll];

    7.在中心视图添加按钮

    1)在中心视图添加头文件

    #import "UIViewController+MMDrawerController.h"//第三方封装的头文件
    #import "MMDrawerBarButtonItem.h"//第三方封装的头文件
    #import "LeftDrawerTableViewController.h"、、左视图头文件

    2)创建按钮的方法

    -(void)setupLeftMenuButton
    {
        //创建按钮
        MMDrawerBarButtonItem * leftDrawerButton = [[MMDrawerBarButtonItem alloc] initWithTarget:self action:@selector(leftDrawerButtonPress:)];

         //为navigationItem添加LeftBarButtonItem
        [self.navigationItem setLeftBarButtonItem:leftDrawerButton animated:YES];
    }

    3)添加按钮的动作

    //抽屉按钮动作
    -(void)leftDrawerButtonPress:(id)sender
    {
        //开关左抽屉
        [self.mm_drawerController toggleDrawerSide:MMDrawerSideLeft animated:YES completion:nil];
    }

  • 相关阅读:
    cad 创建自定义菜单
    标准C++的类型转换符
    Assert usages
    c++排序算法与模板和STL_zhuan
    C++ 中int,char,string,CString类型转换
    C++ 之 C style string
    数据库优化细节——转
    C++容器——zhuan
    公共类库_address:http://www.cnblogs.com/wuhuacong/archive/2012/03/26/2418786.html
    C++学习篇——C++ STL中迭代器介绍(收集)
  • 原文地址:https://www.cnblogs.com/moxuexiaotong/p/4912740.html
Copyright © 2011-2022 走看看