使用 DDMenuController 类的方法(非常好用的抽屉类)
关于使用 DDMenuController 类的方法笔记:参考
DDMenuController 是一款非常好用的抽屉类文件。
#pragma mark - 界面配置左右导航条的按钮 //[self configureLeftButton];//配置导航条左边按钮 [self configureRightButton];//配置导航条右边按钮 上面是要在ViewDidLoad 里面调用的 下面是方法的实现 #pragma mark - 界面配置类 //配置导航条左边按钮 - (void)configureLeftButton { UIBarButtonItem *left = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"qr_toolbar_more_hl"] style:UIBarButtonItemStylePlain target:self action:@selector(handleLeftBack:)]; self.navigationItem.leftBarButtonItem = left; } //配置导航条右边按钮 - (void)configureRightButton { UIBarButtonItem *right = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"qr_toolbar_more_hl"] style:UIBarButtonItemStylePlain target:self action:@selector(handleRightBack:)]; self.navigationItem.rightBarButtonItem = right; } #pragma mark -action //导航条左边按钮点击事件 - (void)handleLeftBack:(UIBarButtonItem *)item { AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate; DDMenuController *menuC = delegate.menuController; [menuC showLeftController:YES]; } //导航条右边按钮点击事件 - (void)handleRightBack:(UIBarButtonItem *)item { AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate; DDMenuController *menuC = delegate.menuController; [menuC showRightController:YES]; }
可以使用appdelegate -(void)leftBtnClick { [(DDMenuController *)[UIApplication sharedApplication].delegate.window.rootViewController showLeftController:YES]; }