第六篇抽屉效果+UITabBarController

Posted 久冬不雨

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了第六篇抽屉效果+UITabBarController相关的知识,希望对你有一定的参考价值。

依赖于第三方的框架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的主要内容,如果未能解决你的问题,请参考以下文章

Core Animation 文档翻译 (第六篇)

第六篇文件处理之文件修改的两种方式

第六篇微信小程序-form组件

AdvancedLocomotionSystemV第六篇 C++ 实现冲刺与身体倾斜

AdvancedLocomotionSystemV第六篇 C++ 实现冲刺与身体倾斜

第六篇:面向对象