下载地址:https://github.com/romaonthego/RESideMenu
效果如下:官方案例
自己的实现效果
具体代码下:
AppDelegate.m文件中
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions方法
DEMOLeftMenuViewController *leftMenuViewController = [[DEMOLeftMenuViewController alloc] init];
RESideMenu *sideMenuViewController = [[RESideMenu alloc] initWithContentViewController:[[MainTabBarController alloc]init] leftMenuViewController:leftMenuViewController rightMenuViewController:[UINavigationController new]];
sideMenuViewController.backgroundImage = [UIImage imageNamed:@"005.jpg"];
sideMenuViewController.menuPreferredStatusBarStyle = 1; // UIStatusBarStyleLightContent
sideMenuViewController.delegate = self;
// sideMenuViewController.parallaxContentMaximumRelativeva lue=100;
// sideMenuViewController.bouncesHorizontally=YES;
sideMenuViewController.contentViewShadowColor = [UIColor blackColor];
sideMenuViewController.contentViewShadowOffset = CGSizeMake(0, 0);
sideMenuViewController.contentViewShadowOpacity = 0.6;
sideMenuViewController.contentViewShadowRadius = 12;
// sideMenuViewController.contentViewShadowEnabled = YES;
// sideMenuViewController.panFromEdge=NO;
self.window.rootViewController = sideMenuViewController;
左侧的控制器DEMOLeftMenuViewController.h和DEMOLeftMenuViewController.m
#import <UIKit/UIKit.h>
#import "RESideMenu.h"
@interface DEMOLeftMenuViewController : UIViewController<UITableViewDataSource, UITableViewDelegate, RESideMenuDelegate>
@end
#import "DEMOLeftMenuViewController.h"
#import "HomeViewController.h"
#import "UIViewController+RESideMenu.h"
#import "LoginViewController.h"
#import "resigeViewController.h"
@interface DEMOLeftMenuViewController ()
@property (strong, readwrite, nonatomic) UITableView *tableView;
@end
@implementation DEMOLeftMenuViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationController.title=@"登陆";
self.tableView = ({
UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, (self.view.frame.size.height - 54 * 5) / 2.0f, self.view.frame.size.width, 54 * 5) style:UITableViewStylePlain];
tableView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleWidth;
tableView.delegate = self;
tableView.dataSource = self;
tableView.opaque = NO;
tableView.backgroundColor = [UIColor clearColor];
tableView.backgroundView = nil;
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
tableView.bounces = NO;
tableView.scrollsToTop = NO;
tableView;
});
[self.view addSubview:self.tableView];
}
#pragma mark -
#pragma mark UITableView Delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
switch (indexPath.row) {
case 0:
[self presentViewController:[[UINavigationController alloc] initWithRootViewController:[[LoginViewController alloc] init]] animated:YES comple