一句代码,集成抽屉效果
this is a drawer effect
// 快速创建抽屉控制器,并设为根控制器
self.window.rootViewController = [LJDrawerViewController drawerVCWithMainVC:tabBarVC leftMenuVC:leftVC leftWidth:0];
/**
快速创建抽屉控制器
@param mainVC 根控制器
@param leftMenuVC 左边的控制器
@param leftWidth 左边的菜单控制器显示的最大范围,默认为屏幕宽度的0.7倍
@return 抽屉控制器
*/
+ (instancetype)drawerVCWithMainVC:(UIViewController *)mainVC leftMenuVC:(UIViewController *)leftMenuVC leftWidth:(CGFloat)leftWidth;`
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
// 左边菜单控制器
LJLeftMenuViewController *leftVC = [[LJLeftMenuViewController alloc] init];
// 根控制器
LJTabBarViewController *tabBarVC = [[LJTabBarViewController alloc] init];
// 快速创建抽屉控制器,并设为根控制器
self.window.rootViewController = [LJDrawerViewController drawerVCWithMainVC:tabBarVC leftMenuVC:leftVC leftWidth:0];
[self.window makeKeyAndVisible];
return YES;
}
/**
打开左边的菜单
*/
- (void)openLeftMenu;
在需要打开时调用:
[[LJDrawerViewController getDrawerViewController] openLeftMenu];