下载文档:点击打开链接
RESideMenu类
所有属性及其方法:
@property (strong, readwrite, nonatomic) UIViewController *contentViewController;
@property (strong, readwrite, nonatomic) UIViewController *leftMenuViewController;
@property (strong, readwrite, nonatomic) UIViewController *rightMenuViewController;
@property (weak, readwrite, nonatomic) id<RESideMenuDelegate> delegate;
@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) IBInspectable BOOL interactivePopGestureRecognizerEnabled;
@property (assign, readwrite, nonatomic) IBInspectable BOOL fadeMenuView;
@property (assign, readwrite, nonatomic) IBInspectable BOOL scaleContentView;
@property (assign, readwrite, nonatomic) IBInspectable BOOL scaleBackgroundImageView;
@property (assign, readwrite, nonatomic) IBInspectable BOOL scaleMenuView;
@property (assign, readwrite, nonatomic) IBInspectable BOOL contentViewShadowEnabled;
@property (strong, readwrite, nonatomic) IBInspectable UIColor *contentViewShadowColor;
@property (assign, readwrite, nonatomic) IBInspectable CGSize contentViewShadowOffset;
@property (assign, readwrite, nonatomic) IBInspectable CGFloat contentViewShadowOpacity;
@property (assign, readwrite, nonatomic) IBInspectable CGFloat contentViewShadowRadius;
@property (assign, readwrite, nonatomic) IBInspectable CGFloat contentViewFadeOutAlpha;
@property (assign, readwrite, nonatomic) IBInspectable CGFloat contentViewScaleValue;
@property (assign, readwrite, nonatomic) IBInspectable CGFloat contentViewInLandscapeOffsetCenterX;
@property (assign, readwrite, nonatomic) IBInspectable CGFloat contentViewInPortraitOffsetCenterX;
@property (assign, readwrite, nonatomic) IBInspectable CGFloat parallaxMenuMinimumRelativeValue;
@property (assign, readwrite, nonatomic) IBInspectable CGFloat parallaxMenuMaximumRelativeValue;
@property (assign, readwrite, nonatomic) IBInspectable CGFloat parallaxContentMinimumRelativeValue;
@property (assign, readwrite, nonatomic) IBInspectable CGFloat parallaxContentMaximumRelativeValue;
@property (assign, readwrite, nonatomic) CGAffineTransform menuViewControllerTransformation;
@property (assign, readwrite, nonatomic) IBInspectable BOOL parallaxEnabled;
@property (assign, readwrite, nonatomic) IBInspectable BOOL bouncesHorizontally;
@property (assign, readwrite, nonatomic) UIStatusBarStyle menuPreferredStatusBarStyle;
@property (assign, readwrite, nonatomic) IBInspectable BOOL menuPrefersStatusBarHidden;
- (id)initWithContentViewController:(UIViewController *)contentViewController
leftMenuViewController:(UIViewController *)leftMenuViewController
rightMenuViewController:(UIViewController *)rightMenuViewController;
- (void)presentLeftMenuViewController;
- (void)presentRightMenuViewController;
- (void)hideMenuViewController;
- (void)setContentViewController:(UIViewController *)contentViewController animated:(BOOL)animated;
@end
@protocol RESideMenuDelegate <NSObject>
@optional
- (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;
RootViewController 继承ReSideMenu
2、创建左left、中content、右right、视图
RootViewController.m文件
设置属性:
RESideMenu类中的所有属性值,全都在下面:
//状态栏的样式
self.menuPreferredStatusBarStyle = UIStatusBarStyleLightContent;
//中心视图的边框阴影
self.contentViewShadowColor = [UIColor blackColor];
//中心视图的边框阴影的偏移量
self.contentViewShadowOffset = CGSizeMake(0, 0);
//中心视图的边框阴影的透明度
self.contentViewShadowOpacity = 0.6;
//中心视图的边框阴影的显示的范围
self.contentViewShadowRadius = 12;
//中心视图的边框阴影是否显示
self.contentViewShadowEnabled = YES;
//中心视图 -- 导航控制器
self.contentViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"contentViewController"];
//左边视图
self.leftMenuViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"leftMenuViewController"];
//右边视图
self.rightMenuViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"rightMenuViewController"];
//背景图片
self.backgroundImage = [UIImage imageNamed:@"Stars"];
//设置中心视图的透明度
self.contentViewFadeOutAlpha = 1;
//设置中心视图的放缩大小
self.contentViewScaleValue = .7;
self.contentViewInLandscapeOffsetCenterX = 30;
//设置中心视图的偏移量
self.contentViewInPortraitOffsetCenterX = 30;
//判断是否可以偏移
self.parallaxEnabled = NO;
//左右视图的偏移量
self.parallaxMenuMinimumRelativeValue = -15;
self.parallaxMenuMaximumRelativeValue = 15;
//中心视图上下的偏移量
self.parallaxContentMinimumRelativeValue = -25;
self.parallaxContentMaximumRelativeValue = 25;
//左右两边字体的放大与缩小
self.menuViewControllerTransformation = CGAffineTransformMakeScale(1.5f, 1.5f);
//中心视图左右是否可以拉伸
self.bouncesHorizontally = YES;
//状态栏是否隐藏
self.menuPrefersStatusBarHidden = NO;
//支持滑动的手势
self.panGestureEnabled = YES;
//支持中心视图上的滑动
self.panFromEdge = NO;
//支持中心视图滑动多大的页面跳转
self.panMinimumOpenThreshold = 60.0;
//设置代理
self.delegate = self;
<RESideMenuDelegate>
代理方法:都是可选择实现的
#pragma mark RESideMenu Delegate
//将要显示菜单控制器的时候调用
- (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
{
}
在contentViewController.m
创建一个类目
- (RESideMenu *)sideMenuViewController
{
UIViewController *iter = self.parentViewController;
while (iter) {
if ([iter isKindOfClass:[RESideMenu class]]) {
return (RESideMenu *)iter;
} else if (iter.parentViewController && iter.parentViewController != iter) {
iter = iter.parentViewController;
} else {
iter = nil;
}
}
return nil;
}
在创建两个左右按钮:
点击左按钮实现的方法:通过响应者链找到控制器调用方法
[self.sideMenuViewController presentLeftMenuViewController];
右:
[self.sideMenuViewController presentRightMenuViewController];
从左右视图回到中心视图时调用的方法:
[self.sideMenuViewController hideMenuViewController];
[self.sideMenuViewController setContentViewController:[[UINavigationController alloc] initWithRootViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"secondViewController"]]
animated:YES];
以上就是RESideMenu的所有方法,属性的使用