zoukankan      html  css  js  c++  java
  • iOS开发——UI进阶篇(十三)UITabBarController简单使用,qq主流框架

    一、UITabBarController简单使用

    // 程序加载完毕
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        
        // 创建窗口
        self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
        
        // 设置窗口的根控制器
        UITabBarController *tabBarVc = [[UITabBarController alloc] init];
        
        self.window.rootViewController = tabBarVc;
        
        
        // 1、添加第1个子控制器
        // 默认tabBarVc显示第0个子控制器的view
        UIViewController *vc = [[UIViewController alloc] init];
        vc.view.backgroundColor = [UIColor redColor];
        
        // 设置这个控制器对应按钮的标题
        vc.tabBarItem.title = @"消息";
        // tabBar控制器默认会选中第0个按钮
        // 在iOS7之后默认会把UITabBar上的选中的按钮图片给渲染成蓝色
        
        // 设置这个控制器对应按钮的图片
        vc.tabBarItem.image = [UIImage imageNamed:@"tab_recent_nor"];
        
        // 设置提醒数字
        vc.tabBarItem.badgeValue = @"1000";
        
        [tabBarVc addChildViewController:vc];
        
        // 2、添加第2个子控制器
        UIViewController *vc1 = [[UIViewController alloc] init];
        vc1.view.backgroundColor = [UIColor blueColor];
        vc1.tabBarItem.title = @"联系人";
        vc1.tabBarItem.image = [UIImage imageNamed:@"tab_buddy_nor"];
        [tabBarVc addChildViewController:vc1];
        
        // 3、添加第3个子控制器
        UIViewController *vc2 = [[UIViewController alloc] init];
        vc2.view.backgroundColor = [UIColor greenColor];
        vc2.tabBarItem.badgeValue = @"10";
        [tabBarVc addChildViewController:vc2];
        
        // 显示窗口
        [self.window makeKeyAndVisible];
        
        
        return YES;
    }

    二、 qq主流框架
    要想让UITabBarController的每个子控制器导航条显示内容都不同
    要设置窗口的根控制器为UITabBarController

    storyboard

    将来的你会感谢今天如此努力的你! 版权声明:本文为博主原创文章,未经博主允许不得转载。
  • 相关阅读:
    清空数据库所有表数据
    sqlserver编号
    Inherits、CodeFile、CodeBehind的区别
    初识NuGet
    ASP.Net各个命名空间及作用
    SQL SERVER数据库性能优化之SQL语句篇
    Exercise 20: Functions And Files
    Exercise 19: Functions And Variables
    Exercise 18: Names, Variables, Code, Functions
    Exercise 17: More Files
  • 原文地址:https://www.cnblogs.com/chglog/p/4697063.html
Copyright © 2011-2022 走看看