簡(jiǎn)介
RESideMenu 是一個(gè)有視差效果的側(cè)邊菜單.
項(xiàng)目主頁(yè):RESideMenu
最新示例:點(diǎn)擊下載
快速入門
環(huán)境要求
Xcode 6 +
Apple LLVM 編譯器
iOS 6.0 +
ARC
安裝
使用 CocoaPods 安裝
platform:ios,'6.0'pod'RESideMenu','~> 4.0.7'
手動(dòng)安裝
把 RESideMenu 相關(guān)類文件拖到你工程中,并在需要使用的地方引入頭文件
#include “RESideMenu.h”
用法
純代碼方式
在你的AppDelegate的- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions創(chuàng)建視圖控制器,并給它設(shè)置用于顯示內(nèi)容和側(cè)邊菜單的視圖控制器.
// 創(chuàng)建內(nèi)容和菜單視圖控制器.
//DEMONavigationController *navigationController = [[DEMONavigationController alloc] initWithRootViewController:[[DEMOHomeViewController alloc] init]];
DEMOLeftMenuViewController *leftMenuViewController = [[DEMOLeftMenuViewController alloc] init];
DEMORightMenuViewController *rightMenuViewController = [[DEMORightMenuViewController alloc] init];
// 創(chuàng)建 RESideMenu 控制器.
//RESideMenu *sideMenuViewController = [[RESideMenu alloc] initWithContentViewController:navigationController? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? leftMenuViewController:leftMenuViewController? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? rightMenuViewController:rightMenuViewController];sideMenuViewController.backgroundImage= [UIImageimageNamed:@"Stars"];
// 將 RESideMenu 控制器設(shè)置為根控制器.//self.window.rootViewController= sideMenuViewController;
顯示側(cè)邊菜單的視圖控制器:
[self.sideMenuViewController presentLeftMenuViewController];
或
[self.sideMenuViewController presentRightMenuViewController];
更改用于顯示內(nèi)容的視圖控制器:
#import....[self.sideMenuViewControllersetContentViewController:viewController animated:YES];[self.sideMenuViewControllerhideMenuViewController];
在 Storyboard 中使用
創(chuàng)建一個(gè)RESideMenu的子類,如DEMORootViewController.
在Storyboard中,將DEMORootViewController指定為 根視圖的 所有者.
在Storyboard中添加更多的視圖控制器,并將他們的標(biāo)識(shí)符設(shè)為“l(fā)eftMenuViewController”,“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;
如果你設(shè)置了backgroundImage,需要同時(shí)設(shè)置背景色為clear color,才會(huì)有效.
你可以實(shí)現(xiàn)RESideMenuDelegate協(xié)議,來(lái)接收和處理以下消息:
-(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;