码迷,mamicode.com
首页 > 移动开发 > 详细

iOS抽屉效果

时间:2014-10-31 12:08:29      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:ios 侧拉栏抽屉效果

源码下载

抽屉效果第三方类库下载

所需第三方类库下载

侧拉栏抽屉效果图

 bubuko.com,布布扣       bubuko.com,布布扣


需要导入的头文件:

#import "MMDrawerController.h"
#import "MMExampleDrawerVisualStateManager.h"
代码实现:

首先需要创建三个试图控制器

//主视图
    FirstViewController *firstVC = [[FirstViewController alloc] init];
    //左边视图
    SecondViewController *secondVC = [[SecondViewController alloc] init];
    //右边视图
    ThirdViewController *thirdVC = [[ThirdViewController alloc] init];
    
    CustomizedNavigationController *navigationVC = [[CustomizedNavigationController alloc] initWithRootViewController:firstVC];
    
    CustomizedNavigationController *leftNavigationVC = [[CustomizedNavigationController alloc] initWithRootViewController:secondVC];

    CustomizedNavigationController *rightNavigationVC = [[CustomizedNavigationController alloc] initWithRootViewController:thirdVC];

    //抽屉管理 第三方
    //该第三方既可以只实现打开左侧栏也可以实现打开右侧栏,还可以同时都实现
    MMDrawerController *rooVC = [[MMDrawerController alloc] initWithCenterViewController:navigationVC leftDrawerViewController:leftNavigationVC rightDrawerViewController:rightNavigationVC];
    
    //只实现打开左侧栏
    //MMDrawerController *rooVCLeft = [[MMDrawerController alloc] initWithCenterViewController:navigationVC leftDrawerViewController:firstVC];
    //只实现打开右侧栏
    //MMDrawerController *rooVCRight = [[MMDrawerController alloc] initWithCenterViewController:navigationVC rightDrawerViewController:thirdVC];
    
    //指定window的根视图
    self.window.rootViewController = rooVC;
    //测了门的宽度
    [rooVC setMaximumLeftDrawerWidth:270];
    //设置侧拉门开与关的动画
    [rooVC setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeAll];
    [rooVC setCloseDrawerGestureModeMask:MMCloseDrawerGestureModeAll];
    //侧开内容展示效果
    //设置向左滑动打开右侧栏
    [[MMExampleDrawerVisualStateManager sharedManager] setRightDrawerAnimationType:MMDrawerAnimationTypeNone];
    //设置向右滑动打开左侧栏
    [[MMExampleDrawerVisualStateManager sharedManager] setLeftDrawerAnimationType:MMDrawerAnimationTypeNone];
    
    [rooVC setDrawerVisualStateBlock:^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) {
        MMDrawerControllerDrawerVisualStateBlock block;
        block = [[MMExampleDrawerVisualStateManager sharedManager]
                 drawerVisualStateBlockForDrawerSide:drawerSide];
        if(block){
            block(drawerController, drawerSide, percentVisible);
        }

    }];




iOS抽屉效果

标签:ios 侧拉栏抽屉效果

原文地址:http://blog.csdn.net/mhtios/article/details/40649721

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!