用于iOS的滑动菜单(顶部和底部菜单)
使用这个库,您可以创建3种类型的滑动菜单
1. 只含顶部的滑动菜单。
2. 只含底部的滑动菜单。
3. 包含顶部和底部菜单的滑动菜单。
克隆仓库
$ git clone https://github.com/Juanpe/JPVerticalSlideMenu.git
将JPVerticalSlideLib
文件夹拖放到项目中。在需要使用它的所有视图控制器中添加#import "JPVerticalSlideViewController.h"
。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UIViewController* vcMain = [[UIViewController alloc] init];
vcMain.view.backgroundColor = [UIColor blueColor];
UIViewController * vcTop = [[UIViewController alloc] init];
vcTop.view.backgroundColor = [UIColor redColor];
UIViewController * vcBottom = [[UIViewController alloc] init];
vcBottom.view.backgroundColor = [UIColor greenColor];
JPVerticalSlideViewController* verticalSlideMenu = [JPVerticalSlideViewController verticalSlideMenuWithMainVC:vcMain
andTopVC:vcTop
andBottomVC:vcBottom];
self.window.rootViewController = verticalSlideMenu;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
您可以通过重写所需方法轻松地自定义滑动菜单,例如
- (CGFloat) topVCHeight; - (CGFloat) bottomVCHeight; - (CGFloat) panGestureWorkingAreaPercent;
您可以通过编程打开或关闭顶部或底部菜单
- (void) openTopVC; - (void) openTopVCAnimated:(BOOL)animated; - (void) openBottomVC; - (void) openBottomVCAnimated:(BOOL)animated; - (void) closeTopVC; - (void) closeTopVCAnimated:(BOOL)animated; - (void) closeBottomVC; - (void) closeBottomVCAnimated:(BOOL)animated;
如果您想获取菜单的打开/关闭回调,必须实现名为JPVerticalSlideVCDelegate
的协议。
@optional - (void) topVCWillOpen; - (void) topVCDidOpen; - (void) bottomVCWillOpen; - (void) bottomVCDidOpen; - (void) topVCWillClose; - (void) topVCDidClose; - (void) bottomVCWillClose; - (void) bottomVCDidClose;