RESideMenu-Q 4.0.7.1

RESideMenu-Q 4.0.7.1

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最后发布2015年12月

qimuya3 维护。



RESideMenu-Q 4.0.7.1

  • Roman Efimov

RESideMenu

iOS 7/8 风格的侧边菜单,具有由 DribbbleASHots启发的视差效果(《第一 和《第二》)。

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

RESideMenu Screenshot RESideMenu Screenshot

要求

  • Xcode 6 或更高版本
  • 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",可以在 Identity 检查器中找到。
  5. DEMORootViewController.m 添加一个方法 awakeFromNib,并使用以下代码
- (void)awakeFromNib
{
    self.contentViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"contentViewController"];
    self.leftMenuViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"leftMenuViewController"];
    self.rightMenuViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"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;

如果您设置了一个背景图像,不要忘记将菜单视图控制器的背景颜色设置为清色。

您可以实现 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。

在此特此授予任何人获得此软件及其相关文档文件(以下简称“软件”)副本(“软件”)的权利,无拘无束地处理软件,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或出售软件副本,并允许向软件提供之人以此类方式进行,受以下条款约束:

上述版权声明和本许可声明应包含或在软件的任何副本或主要部分中。

软件按“原样”提供,明确不用做任何担保,无论明示还是暗示,包括但不限于适销性、特定用途适用性和非侵权性担保。在任何情况下,作者或版权所有者不应对任何索赔、损害或任何其他责任承担责任,无论是在合同、侵权或其他行为中产生的,与软件或使用或操作软件有关,无论在软件内还是在软件外。