XMG UITabBarController

1.构成

 i.控制器的View

 ii.UITabbar

iii.存放其他控制器View的view


2.UITabBar

如果UITabBarController有N个子控制器,那么UITabBar内部就会有N个UITabbBarButton作为子控件

XMG UITabBarController_第1张图片


UITabbar的使用


   

    // 设置窗口的跟控制器

    UITabBarController *tabBarVc = [[UITabBarController alloc] init];

    

    self.window.rootViewController = tabBarVc;

    

    UIViewController *vc = [[UIViewController alloc] init];

    

    vc.view.backgroundColor = [UIColor redColor];

    

    // 添加子控制器

    [tabBarVc addChildViewController:vc];

    

    //  设置按钮上面的内容

    vc.tabBarItem.title = @"消息";

    vc.tabBarItem.image = [[UIImage imageNamed:@"tab_recent_nor"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] ;

    

    

    vc.tabBarItem.badgeValue = @"1000";

    

    UIViewController *vc1 = [[UIViewController alloc] init];

    

    vc1.view.backgroundColor = [UIColor greenColor];

    

    // 添加子控制器

    [tabBarVc addChildViewController:vc1];


    vc1.tabBarItem.title = @"联系人";

    vc1.tabBarItem.badgeValue = @"10";

     vc1.tabBarItem.image = [[UIImage imageNamed:@"tab_recent_nor"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] ; //让图片不被渲染

    

    // 显示窗口

    [self.window makeKeyAndVisible];

    








你可能感兴趣的:(XMG UITabBarController)