iOS UITabBartroller作为根视图

2023-11-19

//

//  RootViewController.m

//  UITabBarCOntrollerDemo

//

//  Created by Dubai on 14/10/4.

//  Copyright (c) 2015 DUbai. All rights reserved.

//


#import "RootViewController.h"


#import "HomeViewController.h"

#import "FindViewController.h"

#import "CategoryViewController.h"

#import "ShoppingViewController.h"

#import "UserViewController.h"

#import "SettingViewController.h"


@interface RootViewController ()


@end


@implementation RootViewController


-(void)viewWillAppear:(BOOL)animated

{

    [superviewWillAppear:animated];

    self.navigationController.navigationBar.translucent = NO;

   self.title =@"123";



}


- (void)viewDidLoad {

    [superviewDidLoad];

    // Do any additional setup after loading the view.

    self.view.backgroundColor = [UIColorgreenColor];

    

    

   //首页

    HomeViewController *homeVc = [[HomeViewControlleralloc] init];

    UINavigationController *homeNC = [[UINavigationControlleralloc] initWithRootViewController:homeVc];

    

    homeNC.tabBarItem.title =@"首页";//53

    homeNC.tabBarItem.image = [UIImageimageNamed:@"53-house.png"];//用在标签上的图片不呢过随便给,必须30*30高清屏 60 *60 (可以有浮动 27 *27 55 * 55 62*62)

    homeNC.tabBarItem.badgeValue =@"12";//提示信息

    

   //分类

    CategoryViewController *categoryVC = [[CategoryViewControlleralloc] init];

    UINavigationController *categoryNC = [[UINavigationControlleralloc] initWithRootViewController:categoryVC];

    categoryNC.tabBarItem.title =@"分类";//06

    categoryNC.tabBarItem.image = [UIImageimageNamed:@"06-magnifying-glass.png"];

    

    

   //发现

    FindViewController *findVC = [[FindViewControlleralloc] init];

    UINavigationController *findNC = [[UINavigationControlleralloc] initWithRootViewController:findVC];

    findNC.tabBarItem.title =@"发现";//12

    findNC.tabBarItem.image = [UIImageimageNamed:@"12-eye.png"];

    

    //    findNC.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:(UITabBarSystemItemSearch) tag:0];//可以自定义标签(系统的自带图片)

    

    //购物车

    ShoppingViewController *shopVC = [[ShoppingViewControlleralloc] init];

    UINavigationController *shopNC = [[UINavigationControlleralloc] initWithRootViewController:shopVC];

    shopNC.tabBarItem.title =@"购物车";//80

    shopNC.tabBarItem.image = [UIImageimageNamed:@"80-shopping-cart.png"];

    

   //用户

    UserViewController *userVC =[[UserViewControlleralloc] init];

    UINavigationController *userNC =[[UINavigationControlleralloc] initWithRootViewController:userVC];

    userNC.tabBarItem.title =@"我的";//22

    userNC.tabBarItem.image = [UIImageimageNamed:@"22-skull-n-crossbones.png"];

    

    

   //设置

    SettingViewController *setVC = [[SettingViewControlleralloc] init];

    UINavigationController *setNV = [[UINavigationControlleralloc] initWithRootViewController:setVC];

    

    setNV.tabBarItem.title =@"设置";

    setNV.tabBarItem.image = [UIImageimageNamed:@"19-gear.png"];//默认是五个.其他的隐藏

    //将创建的controller添加到tabBarController中管理(模块添加)

    //标签设置的图片背景透明(镂空中间扣掉,看到的蓝色是透过来的蓝色)

   self.viewControllers =@[homeNC,categoryNC,findNC,shopNC,userNC,setNV];

    

    

    

    //标签栏的颜色

    self.tabBar.barTintColor = [UIColorgreenColor];//可以统一设置

    //tabVC.tabBar.backgroundColor = [UIColor redColor];

    self.tabBar.tintColor = [UIColorredColor];//被选中的标签的颜色

    //tabVC.tabBar.backgroundImage = [UIImage imageNamed:@"he.png"];//320 *49

    self.selectedIndex =2;//设置首先被选择的标签.

    //tabVC.tabBar.backgroundImage = [UIImage imageNamed:@"he.png"];//标签栏设置背景图片

    

    //UIAppearance协议提供统一设置的方法

    //不是所有属性都支持统一设置,tintColor就不支持.

    //[[UINavigationBar appearance] setBarTintColor:[UIColor blackColor]];

    //[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"ni.png"] forBarMetrics:(UIBarMetricsDefault)];   

}


- (void)didReceiveMemoryWarning {

    [superdidReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}


/*

#pragma mark - Navigation


// In a storyboard-based application, you will often want to do a little preparation before navigation

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    // Get the new view controller using [segue destinationViewController].

    // Pass the selected object to the new view controller.

}

*/


@end

切记:
不要 再把UITabBarController作为导航控制器根视图了...
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

iOS UITabBartroller作为根视图 的相关文章

随机推荐

  • (二十六)admin-boot项目之基于注解的数据字段脱敏

    项目地址 https gitee com springzb admin boot 如果觉得不错 给个 star 简介 这是一个基础的企业级基础后端脚手架项目 主要由springboot为基础搭建 后期整合一些基础插件例如 redis xxl
  • VMware 14 安装win7x64

    所需工具 VMware17 windows镜像 windows镜像在脚本之家下载的 1 新建虚拟机 文件 gt 新建虚拟机 gt 下一步 2 选择 稍候安装操作系统 下一步 3 选择操作系统和版本 下一步 4 设置虚拟机名称和存放位置 选择
  • java动态创建xml文件

    private static void createXml String dest throws Exception DocumentBuilderFactory factory DocumentBuilderFactory newInst
  • Java中占位符的实战运用

    java中的占位符 有以下几种等等 s字符串类型的占位符 b布尔类型的占位符 d整数类型的占位符 c字符类型的占位符 我们大多情况就只用前两种 举个例子 Created by xiwen on 2021 1 14 Slf4j public
  • 常用小工具使用记录整理

    简单记录方便后续使用 1 截图软件 FSCapture exe FSCapture最新版是款适合电脑屏幕中使用的抓屏工具 FSCapture官方版集成了图像捕捉 图像浏览以及图像编辑等功能为一体 帮助用户对截取的图形进行处理操作 并且FSC
  • ionic 解析json串 带(路由 侧拉 效果 上拉刷新 下拉加载)

    先上图看效果 上代码 一般都是 按顺序上代码的
  • 使用STM32高级定时器(TIM8)PWM互补通道输出PWM

    一 为何使用 最近做项目 因为定时器不够用需要用高级定时器 TIM8 来输出PWM来控制电机 刚好硬件工程师把引脚分配到了TIM8定时器CH3的互补通道CH3 ON上 所以需要将CH3 ON当普通的PWM模式输出PWM 特意记录一下 二 下
  • 阿里云Linux热扩容云盘(growpart和resize2fs工具)

    阿里云linux机器系统盘空间不够进行扩容 一 扩容物理盘 阿里云控制台在线扩容完成 二 安装growpart工具和resize2fs工具 root A yum install cloud utils growpart root A yum
  • token保活设计.md

    如果我们要使用token机制用以标识用户登录状态 以获得请求相关资源接口的权限 让你来设计一套方案 以为怎么设计呢 通常有两种思路 1 使用refreshtoken获取新的accesstoken 登录成功之后 返回一个返回refreshto
  • jQuery动态控制单选框选中,实现radio单选框选中后触发事件。prop()选中,取消事件判断。

    input name IS BREAK value 0 prop checked true div class form group div
  • 重读百度移动生态:“第一曲线”的创新“延长线”

    刚刚结束的 WISE2022新经济之王 大会上 百度集团资深副总裁 百度移动生态事业群组总经理何俊杰在主旨演讲中断言 百度搜索 百度APP是AI规模最大的应用场景 随着AI预训练大模型 AIGC 数字人等新技术的规模化落地 其AI带来的创新
  • 【STM32】IIC使用中DMA传输时 发送数据总少一个的问题

    问题描述 在使用STM32 I2C数据发送过程中 发现每轮实际发送出去的数据总比在DMA配置中设定的传输数据个数要少一个 比方说 DMA配置里设定的传输数据个数是10个 结果发现在总线上只能发出9个 经过进一步发现是少了最后一个数据 当对I
  • 简单认识KLT(Kanade-Lucas-Tomasi )跟踪算法

    KLT Kanade Lucas Tomasi 跟踪算法 前言 研究目标跟踪的算法种类颇多 主要可分为两大类 一类是传统的目标跟踪算法 包括粒子滤波 pf Mean Shift及KLT算法 或称Lucas光流法 另一大类是基于深度学习的跟踪
  • 字节跳动笔试---字母交换,最多m次

    参考 https blog csdn net cxzzxc123456 article details 79058419 编码题 字符串S由小写字母构成 长度为n 定义一种操作 每次都可以挑选字符串中任意的两个相邻字母进行交换 询问在至多交
  • [ C语言练习题 5 ] 矩阵转置(将矩阵的行列互换得到的新矩阵)

    题目来源 矩阵转置 牛客题霸 牛客网 描述 KiKi有一个矩阵 他想知道转置后的矩阵 将矩阵的行列互换得到的新矩阵称为转置矩阵 请编程帮他解答 输入描述 第一行包含两个整数n和m 表示一个矩阵包含n行m列 用空格分隔 1 n 10 1 m
  • 使用库函数sqrt求平方根 C语言入门

    欢迎关注笔者 你的支持是持续更博的最大动力 目录 问题描述 库函数 头文件 代码 其他 问题描述 使用库函数sqrt求平方根 库函数 库文件 Library function C C 标准规定的 编译器自带的函数 库函数顾名思义就是库里已存
  • 【QML】如何在QML中添加自定义模块并使用

    一 引言 在 导入本地QML文档目录 一文中 记录了如何导入本地QML文档 本文将记录 如何在QML中使用自定义模块 二 过程记录 本文以一个backend目录来存放自定义的模块 在该目录放置一个Data目录作为模块 其中用于描述模块的就有
  • C语言递归类练习题目

    题目 1 递归和非递归分别实现求第n个斐波那契数 2 编写一个函数实现n k 使用递归实现 3 写一个递归函数DigitSum n 输入一个非负整数 返回组成它的数字之和 例如 调用DigitSum 1729 则应该返回1 7 2 9 它的
  • 如何在Ubuntu上面修改为清华源

    如何在 U b u n t u 上面修改为清华源
  • iOS UITabBartroller作为根视图

    RootViewController m UITabBarCOntrollerDemo Created by Dubai on 14 10 4 Copyright c 2015年 DUbai All rights reserved impo