zoukankan      html  css  js  c++  java
  • iOS学习笔记19抽屉MMDrawerController使用 smallelephant_A

    今天写qq的模仿项目,找到一个比较简单的第三方框架

    MMDrawerController

    下面简单介绍一下 

    MMDrawerController的使用

    预览效果如图

    创建一个抽屉视图

    UIViewController * leftDrawer = [[UIViewController alloc] init];
    UIViewController * center = [[UIViewController alloc] init];
    UIViewController * rightDrawer = [[UIViewController alloc] init];
    
    MMDrawerController * drawerController = [[MMDrawerController alloc]
                                           initWithCenterViewController:center
                                               leftDrawerViewController:leftDrawer
                                               rightDrawerViewController:rightDrawer];



    打开的手势枚举
    • MMOpenDrawerGestureMode

      • MMOpenDrawerGestureModePanningNavigationBar: The user can open the drawer by panning anywhere on the navigation bar.
      • MMOpenDrawerGestureModePanningCenterView: The user can open the drawer by panning anywhere on the center view.
      • MMOpenDrawerGestureModeBezelPanningCenterView: The user can open the drawer by starting a pan anywhere within 20 points of the bezel.
      • MMOpenDrawerGestureModeCustom: The developer can provide a callback block to determine if the gesture should be recognized. More information below.




    下面介绍一个简单的小栗子

    // 第一步在AppDelegate.h中

    @property (strong ,nonatomic) MMDrawerController * drawerController;

    // 然后创建,这里是左中右三个页面,每个页面都用UINavigationController包一层如下

    UINavigationController *rightNavi = [[UINavigationController alloc]initWithRootViewController:_search];

        [rightNavi setRestorationIdentifier:@"RightNavigationControllerRestorationKey"];

        _drawerController = [[MMDrawerController alloc]

                             initWithCenterViewController:center

     leftDrawerViewController:leftNavi

                             rightDrawerViewController:rightNavi];

        [self.drawerController setShowsShadow:NO];

        [self.drawerController setRestorationIdentifier:@"MMDrawer"];

    // 设置右边页面显示宽度,左边同理

    [self.drawerController setMaximumRightDrawerWidth:ScreenWidth];

    // 左右滑动,三个页面间切换

        [self.drawerController setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeAll];

        [self.drawerController setCloseDrawerGestureModeMask:MMCloseDrawerGestureModeAll];

    // 设为根视图

    [self.window setRootViewController:_drawerController];

    // 需要注意的是如果使用按钮实现push,pop功能,在左中右三个页面上不能使用self.navigationcontroller.pushviewcontroller而是使用mm自带的 中间页面可用如下代码

    [self.mm_drawerController openDrawerSide:MMDrawerSideLeft

                                        animated:YES

                                      completion:^(BOOL finished) {

            

        }];

    // openDrawerSide 指的是方向 功能同上面手势功能一样

    // 左右页面对应使用返回,例如写在左上角的返回按钮的点击事件里如下

    //[button addTarget:self action:@selector(clickLeft) //forControlEvents:UIControlEventTouchUpInside];

     //   UIBarButtonItem* backItem = [[UIBarButtonItem alloc] //initWithC

    ustomView:button];

        

        [self.navigationItem setLeftBarButtonItem:backItem];

    [self.mm_drawerController closeDrawerAnimated:YES completion:^(BOOL finished) {

        }];

    代码见 github:https://github.com/Disneydusunan/6-TEST--MMDWRAWER-



  • 相关阅读:
    代码4
    readline,readlines,read函数
    代码3
    find函数
    字典的循环和if语句
    代码2
    代码1
    python除法
    字符串
    print函数
  • 原文地址:https://www.cnblogs.com/adodo/p/5215411.html
Copyright © 2011-2022 走看看