码迷,mamicode.com
首页 > 其他好文 > 详细

第六篇、抽屉效果+UITabBarController

时间:2016-11-05 14:51:11      阅读:141      评论:0      收藏:0      [点我收藏+]

标签:from   uitable   object   git   框架   bool   ges   功能   roo   

依赖于第三方的框架RESideMenu

1.AppDelegate.m中的实现

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    
    //在AppDelegate.h中声明属性,初始化tabBarController
    self.tabBar = [[UITabBarController alloc] init];
    
    ViewController* vc1 = [[ViewController alloc] init];
    vc1.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemBookmarks tag:0];
    UINavigationController* nav1 = [[UINavigationController alloc] initWithRootViewController:vc1];
    
    ViewController1* vc2 = [[ViewController1 alloc] init];
    vc2.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemContacts tag:1];
    UINavigationController* nav2 = [[UINavigationController alloc] initWithRootViewController:vc2];
    
    self.tabBar.viewControllers = @[nav1,nav2];
    
    
    //初始化leftVC
    LeftController* left = [[LeftController alloc] init];
   
    //初始化RESideMenu
    RESideMenu* menu = [[RESideMenu alloc] initWithContentViewController:self.tabBar leftMenuViewController:left rightMenuViewController:nil];
    self.window.rootViewController= menu;
    return YES;
}

 

2.left左侧菜单

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    AppDelegate* GHDelegate = (AppDelegate* )[UIApplication sharedApplication].delegate;
    ViewController1_1* vc = [[ViewController1_1 alloc] init];
    
    //通过GHDelegate.tabBar.selectedIndex获得当前tabbaritem对应的nav,进行页面跳转
    NSArray *arrControllers = GHDelegate.tabBar.viewControllers;
    
    if (GHDelegate.tabBar.selectedIndex==0) {
        UINavigationController* nav = (UINavigationController* )[arrControllers objectAtIndex:0];
        //隐藏sideMenuViewController
        [self.sideMenuViewController hideMenuViewController];
        //隐藏底部
        vc.hidesBottomBarWhenPushed = YES;
        [nav pushViewController:vc animated:YES];
    }else{
        UINavigationController* nav = (UINavigationController* )[arrControllers objectAtIndex:1];
        [self.sideMenuViewController hideMenuViewController];
        vc.hidesBottomBarWhenPushed = YES;
        [nav pushViewController:vc animated:YES];
    }
    
}

 

3.RESideMenu常见的属性设置

- (void)awakeFromNib
{
    self.parallaxEnabled = NO;  //视图差效果
    self.scaleContentView = YES;  //中心视图缩放功能打开
    self.contentViewScaleValue = 0.95;  //侧滑出现时缩放比
    self.scaleMenuView = NO;        //侧滑出来的视图是否支持缩放
    self.contentViewShadowEnabled = YES; //中心视图阴影效果,打开显得有层次感。
    self.contentViewShadowRadius = 4.5;  //中心视图阴影效果Radius
    self.panGestureEnabled = NO;   //关闭拖动支持手势


//使用storyboard初始化中心视图和左视图。
    self.contentViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"contentViewController"];  //tabbar controller 

    self.leftMenuViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"leftMenuViewController"];
}

 

第六篇、抽屉效果+UITabBarController

标签:from   uitable   object   git   框架   bool   ges   功能   roo   

原文地址:http://www.cnblogs.com/HJQ2016/p/6033002.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!