iOS侧拉栏抽屉效果Demo

源码下载

侧拉栏抽屉效果Demo

需要导入第三方的类库如下:

抽屉效果所需第三方类库下载

效果:既可以两侧都实现抽屉效果也可只实现左侧栏或者右侧栏的抽屉效果

                          

关于抽屉效果主要是AppDelegate的代码

AppDelegate.h文件代码:

<span style="font-size:18px;"><span style="font-size:18px;">#import <UIKit/UIKit.h>

@interface YJFAppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@end</span></span>

AppDelegate.m文件代码

<span style="font-size:18px;"><span style="font-size:24px;"><span style="font-size:18px;">#import "YJFAppDelegate.h"
#import "CustomizedNavigationController.h"
#import "FirstViewController.h"
#import "SecondViewController.h"
#import "ThirdViewController.h"
@implementation YJFAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    //主视图
    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);
        }

    }];

    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    return YES;
}</span>
</span>
</span>
时间: 2024-08-03 09:36:53

iOS侧拉栏抽屉效果Demo的相关文章

iOS开发之抽屉效果实现

说道抽屉效果在iOS中比较有名的第三方类库就是PPRevealSideViewController.一说到第三方类库就自然而然的想到我们的CocoaPods,今天的博客中用CocoaPods引入PPRevealSideViewController,然后在我们的工程中以代码结合storyboard来做出抽屉效果. 一.在工程中用CocoaPods引入第三方插件PPRevealSideViewController. (1).在终端中搜索PPRevealSideViewController的版本 (2

ToolBar和DrawerLayout的使用实现侧拉栏抽屉的开闭

1.如图可以看到textColorPrimary,colorPrimary,colorPrimaryDark,navigationBarColor等颜色属性代表的相应位置,如下图 2.具体属性在res的style.xml中更改,如下图,另外在Android.Manifest的里面需要将theme改成对应的AppTheme,如图中所示(注意需要选择NoActionBar的主题作为父类,因为我们不用到ActionBar,而是用ToolBar替代) 3.接下来需要在主xml文件即activity_ma

iOS开发中抽屉效果的第三方库MMDrawerController的使用

1 // 2 3 // AppDelegate.m 4 5 // MMDrawerController 6 7 // 8 9 // Created by yl on 16/6/24. 10 11 // Copyright © 2016年 Itsimple. All rights reserved. 12 13 // 14 15 16 17 #import "AppDelegate.h" 18 19 #import "YLNavigationController.h"

iOS抽屉效果

源码下载 抽屉效果第三方类库下载 所需第三方类库下载 侧拉栏抽屉效果图         需要导入的头文件: #import "MMDrawerController.h" #import "MMExampleDrawerVisualStateManager.h" 代码实现: 首先需要创建三个试图控制器 //主视图 FirstViewController *firstVC = [[FirstViewController alloc] init]; //左边视图 Seco

ios开发中超简单抽屉效果(MMDrawerController)的实现

ios开发中,展示类应用通常要用到抽屉效果,由于项目需要,本人找到一个demo,缩减掉一些不常用的功能,整理出一个较短的实例. 首先需要给工程添加第三方类库 MMDrawerController: 这里讲的实例只加入了左滑抽屉.右滑和左滑只是初始化时多添加一个右视图控制器,其他方法基本相同. 下面是用手势实现抽屉的拉出和收回 1.初始化跟视图控制器时,在AppDelegate中导入头文件 #import "MMDrawerController.h" 2.初始化方法先初始化左视图和中心视

iOS中 超简单抽屉效果(MMDrawerController)的实现

ios开发中,展示类应用通常要用到抽屉效果,由于项目需要,本人找到一个demo,缩减掉一些不常用的功能,整理出一个较短的实例. 首先需要给工程添加第三方类库 MMDrawerController: 这里讲的实例只加入了左滑抽屉.右滑和左滑只是初始化时多添加一个右视图控制器,其他方法基本相同. 下面是用手势实现抽屉的拉出和收回 1.初始化跟视图控制器时,在AppDelegate中导入头文件 #import "MMDrawerController.h" 2.初始化方法先初始化左视图和中心视

iOS实现抽屉效果

抽屉效果 在iOS中很多应用都用到了抽屉效果,例如腾讯的QQ,百度贴吧- --- 1. 最终效果如下图所示 --- 2.实现步骤 1.开始启动的时候,新建3个不同颜色的View的 1.设置3个成员属性,记录三种颜色的View @property (nonatomic,weak) UIView* redView; @property (nonatomic,weak) UIView* greenView; @property (nonatomic,weak) UIView* blueView; 2.

ios 基于CAEmitterLayer的雪花,烟花,火焰,爱心等效果demo(转)

转载自:http://blog.csdn.net/mad2man/article/details/16898369 分类: cocoa SDK2013-11-23 11:52 388人阅读 评论(0) 收藏 举报 demo功能:基于CAEmitterLayer的雪花,烟花,火焰,爱心等效果. demo说明:基于Core Animation的粒子发射系统,粒子用CAEmitterCell来初始化. 粒子画在背景层盒边界上 demo截屏: emitterPosition:发射位置 emitterSi

iOS抽屉效果和侧边菜单

iOS抽屉效果和侧边菜单 源码下载地址 1.效果演示 1. 抽屉效果演示 1. 侧边菜单演示 2.使用说明 构造方法 initialization /// 构造方法(左控制器 & 右控制器 & 背景图片) -(instancetype)initWithLeftController:(UIViewController *)leftController andMainController:(UIViewController *)mainController andRightController