RESideMenu 4.0.7

RESideMenu 4.0.7

测试已测试
Lang语言 Obj-CObjective C
许可证 MIT
发布最新发布2014年12月

Roman Efimov维护。



  • 作者
  • Roman Efimov

受照 Dribbble 射击的 iOS 7/8 风格侧边菜单,具有视差效果(第一个第二个)。

从版本 4.0 开始,您可以在内容视图控制器左右两侧添加菜单视图控制器。

RESideMenu Screenshot RESideMenu Screenshot

要求

  • xcode 5 或更高
  • Apple LLVM 编译器
  • iOS 6.0 或更高
  • ARC

演示

在 xcode 中构建并运行 RESideMenuExample 项目,以查看 RESideMenu 的实际效果。对于故事板集成演示,构建并运行 RESideMenuStoryboardsExample

安装

手动安装

您需要做的就是将 RESideMenu 文件拖放到您的项目中,并于要使用它的类顶部添加 #include "RESideMenu.h"

示例用法

在您的 AppDelegate 的 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 中创建视图控制器,并将内容视图控制器和菜单视图控制器分配给它。

// Create content and menu controllers
//
DEMONavigationController *navigationController = [[DEMONavigationController alloc] initWithRootViewController:[[DEMOHomeViewController alloc] init]];
DEMOLeftMenuViewController *leftMenuViewController = [[DEMOLeftMenuViewController alloc] init];
DEMORightMenuViewController *rightMenuViewController = [[DEMORightMenuViewController alloc] init];

// Create side menu controller
//
RESideMenu *sideMenuViewController = [[RESideMenu alloc] initWithContentViewController:navigationController
                                                                leftMenuViewController:leftMenuViewController
                                                               rightMenuViewController:rightMenuViewController];
sideMenuViewController.backgroundImage = [UIImage imageNamed:@"Stars"];

// Make it a root controller
//
self.window.rootViewController = sideMenuViewController;

呈现菜单视图控制器

[self.sideMenuViewController presentLeftMenuViewController];

[self.sideMenuViewController presentRightMenuViewController];

切换内容视图控制器

#import <RESideMenu/RESideMenu.h>

....

[self.sideMenuViewController setContentViewController:viewController animated:YES];
[self.sideMenuViewController hideMenuViewController];

故事板示例

  1. 创建 RESideMenu 的一个子类。在这个示例中,我们称之为 DEMORootViewController
  2. 在 Storyboard 中将根视图的所有者指定为 DEMORootViewController
  3. 确保在 DEMORootViewController.h 中导入 #import "RESideMenu.h"
  4. 向您的 Storyboard 添加更多视图控制器,并为他们分配标识符 "leftMenuViewController"、"rightMenuViewController" 和 "contentViewController"。注意,在新 Xcode 中标识符称为 "Storyboard ID",可以在身份检查器中找到。
  5. awakeFromNib 方法添加到 DEMORootViewController.m 中,代码如下:
- (void)awakeFromNib
{
    self.contentViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"contentViewController"];
    self.leftMenuViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"leftMenuController"];
    self.rightMenuViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"rightMenuController"];
}

定制

您可以自定义以下 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;

如果您设置了背景图,别忘了将菜单视图控制器的背景色设置为清除色。

您可以通过实现 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;

联系

Roman Efimov

许可证

RESideMenu遵循MIT许可。

版权所有 © 2013 Roman Efimov。

在此特此免费地向任何获得此软件和相关文档副本(统称为"软件")的人授予在此软件上不受限制地处理的权利,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售软件的副本,以及允许向其提供软件的人进行此类行为,前提是遵守以下条件:

上述版权声明和本使用许可声明应包括在软件的所有副本或主要部分的软件中。

该软件按"原样"提供,不提供任何明示或暗示的保证,包括但不限于适销性、适用于特定目的和非侵权性保证。在任何情况下,作者或版权所有者都无需对任何索赔、损害或其他责任负责,无论是基于合同、侵权或其他行为,不论是否存在与软件或其使用有关的事件、事实或情况。