iOS抽屜效果
來源:程序員人生 發布時間:2014-11-07 08:33:25 閱讀次數:2203次
源碼下載
抽屜效果第3方類庫下載
所需第3方類庫下載
側拉欄抽屜效果圖

需要導入的頭文件:
#import "MMDrawerController.h"
#import "MMExampleDrawerVisualStateManager.h"
代碼實現:
首先需要創建3個試圖控制器
//主視圖
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);
}
}];
生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈