ECSlidingViewController

ECSlidingViewController是左右抽屉的三方库,可用cocoapods导入。

1、#import "ECSlidingViewController.h"

2、SlideMenuViewController *slideMenu=[[SlideMenuViewController alloc]init];//主界面

LeftMenuViewController *leftMenu=[[LeftMenuViewController alloc]init];//左界面

RightMenuViewController *rightMenu=[[RightMenuViewController alloc]init];//右界面

ECSlidingViewController *slidingVC=[[ECSlidingViewController alloc]init];

[slidingVC setTopViewController:slideMenu];//设置主界面

slidingVC.underLeftViewController=leftMenu;//设置左界面

slidingVC.underRightViewController=rightMenu;//设置右界面

slideMenu.slidingVC=slidingVC;

leftMenu.slidingVC=slidingVC;

leftMenu.view.layer.borderWidth    = 20;

leftMenu.view.layer.backgroundColor = [UIColor colorWithWhite:0.9 alpha:1.0].CGColor;

leftMenu.view.layer.borderColor    = [UIColor colorWithWhite:0.8 alpha:1.0].CGColor;

leftMenu.edgesForExtendedLayout    = UIRectEdgeTop | UIRectEdgeBottom | UIRectEdgeLeft; 

rightMenu.view.layer.borderWidth    = 20;

rightMenu.view.layer.backgroundColor = [UIColor colorWithWhite:0.9 alpha:1.0].CGColor;

rightMenu.view.layer.borderColor    = [UIColor colorWithWhite:0.8 alpha:1.0].CGColor;

rightMenu.edgesForExtendedLayout    = UIRectEdgeTop | UIRectEdgeBottom | UIRectEdgeRight; 

[nav.view addGestureRecognizer:slidingVC.panGesture];//添加左滑右滑手势

[nav.view addGestureRecognizer:slidingVC.resetTapGesture];//添加出现左/右界面时点击主界面返回主界面的手势

slidingVC.anchorRightPeekAmount  = 100.0;//右边偏移量

slidingVC.anchorLeftRevealAmount = 250.0;//左边偏移量

delegate.window.rootViewController=slidingVC;//设置为window的rootViewController

你可能感兴趣的:(ECSlidingViewController)