代碼,你會得到:如何使用SWRevealViewController
這裏先初始化視圖控制器
FirstViewController * first = [[FirstViewController alloc]init];
SecondViewController * second = [[SecondViewController alloc]init];
創建BarButton ....
UIBarButtonItem *revealButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"reveal-icon"] style:UIBarButtonItemStylePlain target:_revealVC action:@selector(revealToggleAnimated:)];
把firstView控制器和secondViewController導入導航 首先隱藏self.navigationbar self.navigationController.navigationBarHidden = YES;
UINavigationController * navigationController1 = [[UINavigationController alloc] initWithRootViewController:first];
navigationController.navigationBar.topItem.leftBarButtonItem = revealButton
UINavigationController * navigationController2 = [[UINavigationController alloc] initWithRootViewController:second];
navigationController.navigationBar.topItem.leftBarButtonItem = revealButton
初始化SWRevealViewController
_revealVC= [[SWRevealViewController alloc]initWithRearViewController:navigationController1 frontViewController:navigationController2];
_revealVC.rightViewController =nil;
_revealVC.rearViewRevealWidth = 60;
_revealVC.rearViewRevealOverdraw = 0;
_revealVC.bounceBackOnOverdraw = YES;
_revealVC.stableDragOnOverdraw = YES;
_revealVC.rightViewRevealWidth = 350;
_revealVC.rightViewRevealOverdraw = 0;
[_revealVC setFrontViewPosition:FrontViewPositionRight];
[_revealVC revealToggleAnimated:YES];
[self.navigationController setViewControllers:[NSArray arrayWithObject:_revealVC] animated:true];
希望它會幫助你
感謝您的回答。 – Satish