抽屉式图图

AppDelegate.m

AppDelegate.m
#import "LeftViewController.h"
#import "ViewController.h"
@interface AppDelegate ()
#define SCREEN_W  [UIScreen mainScreen].bounds.size.width
///屏幕高度的宏
#define SCREEN_H  [UIScreen mainScreen].bounds.size.height

///适配x轴的宏
#define FIT_X(w) (SCREEN_W / 375. * (w))
///适配y轴的宏
#define FIT_Y(h) (SCREEN_H / 667. * (h))
@property (nonatomic,strong)LeftViewController
*leftVC; //左侧菜单控制器
@property(nonatomic,strong)ViewController *vc;
@property(nonatomic,strong)UINavigationController *nav;
@end

@implementation AppDelegate

//左侧菜单
-(LeftViewController *)leftVC{
    if (!_leftVC) {
        _leftVC = [[LeftViewController alloc]init];
    }
    return _leftVC;
}
//导航控制器
-(UINavigationController *)nav{
    if (!_nav) {
        _nav=[[UINavigationController alloc]initWithRootViewController:self.vc];
    }
    return _nav;
}

//主控制器
-(ViewController *)vc{
    if (!_vc) {
        _vc = [[ViewController alloc]init];
        _vc.view.backgroundColor=[UIColor whiteColor];
    }
    return _vc;
}

//侧滑控制器
-(RESideMenu *)sideMenu{
    if (!_sideMenu) {
        
        _sideMenu = [[RESideMenu alloc]initWithContentViewController:self.nav leftMenuViewController:self.leftVC rightMenuViewController:nil];
        //背景图设置
        _sideMenu.backgroundImage = [UIImage imageNamed:@"Stars"];//stars为背景图片名字
        //内容试图不可缩放
        _sideMenu.scaleContentView = NO;
        
        _sideMenu.contentViewInPortraitOffsetCenterX = FIT_X(100);
        
        
    }
    return _sideMenu;
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    self.window.rootViewController = self.sideMenu;    return YES;
}





- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    //关键部分
    //设置导航栏左按钮
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"bei" style:UIBarButtonItemStylePlain target:self action:@selector(headBtnHandle:)];
   
}
//头像按钮触发方法
-(void)headBtnHandle:(id)sender{
    
    AppDelegate *appDele =(AppDelegate *) [UIApplication sharedApplication].delegate;
 
    [appDele.sideMenu presentLeftMenuViewController];
}

你可能感兴趣的:(抽屉式图图)