簡述
最近項(xiàng)目中用到一個抽屜效果,嘗試自己寫了一個,將過程記錄下來, 有新需求改起來非常方便。我先實(shí)現(xiàn)最基本的功能。

效果圖
圖片比較糙,冷汗...
源代碼
功能
一個抽屜效果
- 1.能過管理多個ViewController
- 2.支持滑動手勢
使用方法
RootViewController * rootVC = [[RootViewController alloc] init];
SecondViewController * secondVC = [[SecondViewController alloc] init];
LeftViewController * leftVC = [[LeftViewController alloc] init];
PZSlideMenu * menu = [[PZSlideMenu alloc] initWithLeftVC:leftVC viewControllers:@[rootVC, secondVC]];
// menu.openOffset = 180;
// menu.scale = 0.7;
self.window.rootViewController = menu;
方法介紹
/**
@ 所管理的viewControllers
*/
@property (nonatomic, strong) NSArray * viewControllers;
/**
@ 抽屜打開的最大距離,默認(rèn)150;
*/
@property (nonatomic, assign) CGFloat openOffset;
/**
@ 當(dāng)打開菜單時,內(nèi)容頁縮放為原來的百分比,(0.5-1)
@ 默認(rèn)為0.85
*/
@property (nonatomic, assign) CGFloat scale;
/**
@ 當(dāng)前打開的ViewController序列
*/
@property (nonatomic, readonly, assign) NSInteger currentOpenedIndex;
/**
@ 是否打開leftVC
*/
@property (nonatomic, assign) BOOL isOpened;
+ (instancetype)shareInstance;
/**
@ 初始化
@ leftVC:左側(cè)菜單
@ VCs:被管理的controllers,NSArray
*/
- (instancetype)initWithLeftVC:(UIViewController *)leftVC viewControllers:(NSArray *)VCs;
/**
@ 打開菜單
*/
- (void)showLeftMenu;
/**
@ 關(guān)閉菜單
*/
- (void)closeLeftMenu;
/**
@ 切換到第幾個controller
*/
- (void)openViewControllerAtIndex:(NSInteger)index;