国内最全IT社区平台 联系我们 | 收藏本站
华晨云阿里云优惠2
您当前位置:首页 > 互联网 > iOS侧拉栏抽屉效果Demo

iOS侧拉栏抽屉效果Demo

来源:程序员人生   发布时间:2014-11-06 11:19:01 阅读次数:3756次


源码下载

侧拉栏抽屉效果Demo
 需要导入第3方的类库以下:


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



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


关于抽屉效果主要是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]; //抽屉管理 第3方 //该第3方既可以只实现打开左边栏也能够实现打开右边栏,还可以同时都实现 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>


生活不易,码农辛苦
如果您觉得本网站对您的学习有所帮助,可以手机扫描二维码进行捐赠
程序员人生
------分隔线----------------------------

上一篇 phpMyAdmin

下一篇 一次面试一次成长

分享到:
------分隔线----------------------------
关闭
程序员人生