RESideMenu 有视差效果的侧边菜单

简介

RESideMenu 是一个有视差效果的侧边菜单.

项目主页:RESideMenu

最新示例:点击下载

快速入门

环境要求

Xcode 6 +

Apple LLVM 编译器

iOS 6.0 +

ARC

安装

使用 CocoaPods 安装

platform:ios,'6.0'pod'RESideMenu','~> 4.0.7'

手动安装

把 RESideMenu 相关类文件拖到你工程中,并在需要使用的地方引入头文件

#include “RESideMenu.h”

用法

纯代码方式

在你的AppDelegate的- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions创建视图控制器,并给它设置用于显示内容和侧边菜单的视图控制器.

// 创建内容和菜单视图控制器.

//DEMONavigationController *navigationController = [[DEMONavigationController alloc] initWithRootViewController:[[DEMOHomeViewController alloc] init]];

DEMOLeftMenuViewController *leftMenuViewController = [[DEMOLeftMenuViewController alloc] init];

DEMORightMenuViewController *rightMenuViewController = [[DEMORightMenuViewController alloc] init];

// 创建 RESideMenu 控制器.

//RESideMenu *sideMenuViewController = [[RESideMenu alloc] initWithContentViewController:navigationController                                                                leftMenuViewController:leftMenuViewController                                                              rightMenuViewController:rightMenuViewController];sideMenuViewController.backgroundImage= [UIImageimageNamed:@"Stars"];

// 将 RESideMenu 控制器设置为根控制器.//self.window.rootViewController= sideMenuViewController;

显示侧边菜单的视图控制器:

[self.sideMenuViewController presentLeftMenuViewController];

[self.sideMenuViewController presentRightMenuViewController];

更改用于显示内容的视图控制器:

#import....[self.sideMenuViewControllersetContentViewController:viewController animated:YES];[self.sideMenuViewControllerhideMenuViewController];

在 Storyboard 中使用

创建一个RESideMenu的子类,如DEMORootViewController.

在Storyboard中,将DEMORootViewController指定为 根视图的 所有者.

在Storyboard中添加更多的视图控制器,并将他们的标识符设为“leftMenuViewController”,“rightMenuViewController”和”contentViewController”.

在你的DEMORootViewController.m中添加方法awakeFromNib, 代码类似下面这样:

- (void)awakeFromNib{self.contentViewController= [self.storyboardinstantiateViewControllerWithIdentifier:@"contentViewController"];self.leftMenuViewController= [self.storyboardinstantiateViewControllerWithIdentifier:@"leftMenuViewController"];self.rightMenuViewController= [self.storyboardinstantiateViewControllerWithIdentifier:@"rightMenuViewController"];}

自定义

你可以自定义RESideMenu的以下属性:

@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 scaleContentView;

@property(assign,readwrite,nonatomic)BOOL scaleBackgroundImageView;

@property(assign,readwrite,nonatomic)BOOL scaleMenuView;

@property(assign,readwrite,nonatomic)BOOL contentViewShadowEnabled;

@property(assign,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 contentViewScaleValue;

@property(assign,readwrite,nonatomic)CGFloat contentViewInLandscapeOffsetCenterX;

@property(assign,readwrite,nonatomic)CGFloat contentViewInPortraitOffsetCenterX;

@property(assign,readwrite,nonatomic)CGFloat parallaxMenuMinimumRelativeValue;

@property(assign,readwrite,nonatomic)CGFloat parallaxMenuMaximumRelativeValue;

@property(assign,readwrite,nonatomic)CGFloat parallaxContentMinimumRelativeValue; 

@property(assign,readwrite,nonatomic)CGFloat parallaxContentMaximumRelativeValue;

@property(assign,readwrite,nonatomic) CGAffineTransform menuViewControllerTransformation;

@property(assign,readwrite,nonatomic)BOOL parallaxEnabled;

@property(assign,readwrite,nonatomic)BOOL bouncesHorizontally;

@property(assign,readwrite,nonatomic) UIStatusBarStyle menuPreferredStatusBarStyle;

@property(assign,readwrite,nonatomic)BOOL menuPrefersStatusBarHidden;

如果你设置了backgroundImage,需要同时设置背景色为clear color,才会有效.

你可以实现RESideMenuDelegate协议,来接收和处理以下消息:

-(void)sideMenu:(RESideMenu*)sideMenu didRecognizePanGesture:(UIPanGestureRecognizer *)recognizer;

-(void)sideMenu:(RESideMenu*)sideMenu willShowMenuViewController:(UIViewController *)menuViewController;

-(void)sideMenu:(RESideMenu*)sideMenu didShowMenuViewController:(UIViewController *)menuViewController;

-(void)sideMenu:(RESideMenu*)sideMenu willHideMenuViewController:(UIViewController *)menuViewController;

-(void)sideMenu:(RESideMenu*)sideMenu didHideMenuViewController:(UIViewController *)menuViewController;

你可能感兴趣的:(RESideMenu 有视差效果的侧边菜单)