侧边抽屉导航
在Xcode中构建并运行Example
项目,以查看ITRAirSideMenu
的实际效果。
所有你需要的只是将ITRAirSideMenu
文件放入你的项目中,并在使用它的类的顶部添加#include "ITRAirSideMenu.h"
。
在你的AppDelegate的- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
中创建视图控制器并分配内容视图控制器和菜单视图控制器。
// Create content and menu controllers
//
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:[ITRFirstViewController controller]];
ITRLeftMenuController *leftMenuViewController = [ITRLeftMenuController controller];
// Create side menu controller
//
ITRAirSideMenu *itrAirSideMenu = [[ITRAirSideMenu alloc] initWithContentViewController:navigationController leftMenuViewController:leftMenuViewController];
itrAirSideMenu.backgroundImage = [UIImage imageNamed:@"menu_bg"];
// Make it a root controller
//
self.window.rootViewController = itrAirSideMenu;
你可以手动显示它
[self.itrAirSideMenu presentLeftMenuViewController];
或使用滑动手势识别器
切换内容视图控制器
#import "ITRAirSideMenu.h"
....
[self.itrAirSideMenu setContentViewController:viewController animated:YES];
[self.itrAirSideMenu hideMenuViewController];
你可以自定义ITRAirSideMenu
的以下属性
@property (assign, readwrite, nonatomic) NSTimeInterval animationDuration;
@property (strong, readwrite, nonatomic) UIImage *backgroundImage;
@property (assign, readwrite, nonatomic) BOOL panGestureEnabled;
@property (assign, readwrite, nonatomic) BOOL panFromEdge;
@property (assign, readwrite, nonatomic) NSUInteger panMinimumOpenThreshold;
@property (assign, readwrite, nonatomic) BOOL interactivePopGestureRecognizerEnabled;
@property (assign, readwrite, nonatomic) BOOL contentViewShadowEnabled;
@property (strong, readwrite, nonatomic) UIColor *contentViewShadowColor;
@property (assign, readwrite, nonatomic) CGSize contentViewShadowOffset;
@property (assign, readwrite, nonatomic) CGFloat contentViewShadowOpacity;
@property (assign, readwrite, nonatomic) CGFloat contentViewShadowRadius;
@property (assign, readwrite, nonatomic) CGFloat contentViewFadeOutAlpha;
@property (assign, readwrite, nonatomic) CGFloat contentViewScaleValue;
@property (assign, readwrite, nonatomic) CGFloat contentViewRotatingAngle;
@property (assign, readwrite, nonatomic) CGFloat contentViewTranslateX;
@property (assign, readwrite, nonatomic) CGFloat menuViewRotatingAngle;
@property (assign, readwrite, nonatomic) CGFloat menuViewTranslateX;
如果你设置了一个背景图像,别忘了将菜单视图控制器的背景颜色设置为透明色。
你可以实现ITRAirSideMenuDelegate
协议来接收以下消息
- (void)sideMenu:(ITRAirSideMenu *)sideMenu didRecognizePanGesture:(UIPanGestureRecognizer *)recognizer;
- (void)sideMenu:(ITRAirSideMenu *)sideMenu willShowMenuViewController:(UIViewController *)menuViewController;
- (void)sideMenu:(ITRAirSideMenu *)sideMenu didShowMenuViewController:(UIViewController *)menuViewController;
- (void)sideMenu:(ITRAirSideMenu *)sideMenu willHideMenuViewController:(UIViewController *)menuViewController;
- (void)sideMenu:(ITRAirSideMenu *)sideMenu didHideMenuViewController:(UIViewController *)menuViewController;
Kiruthika
ITRAirSideMenu可在MIT许可下使用。
版权(c)2015 ITechRoof。
特此授予任何获得此软件及其相关文档副本(以下简称“软件”)的人以免费使用、复制、修改、合并、发布、分发、转授和使用许可的权利,允许用户向获得软件的人转授上述权利,但必须遵守以下条件
上述版权声明和本许可声明应包含在软件所有副本或主要部分中。
本软件按“现状”提供,不提供任何形式的保证,无论是明确的还是隐含的,包括但不限于对适销性、特定目的适用性和非侵权的保证。在任何情况下,作者或版权所有者都不应对任何索赔、损害或其他责任负责,无论这些责任是基于合同行为、侵权或其他任何与软件或其使用或其他任何与软件有关的行为而产生的。