当前位置:网站首页>TabbarController的封装
TabbarController的封装
2022-07-26 09:22:00 【~轻舟~】
首先建立一个类继承自UITabBarController
.m中实现代码:
- (void)viewDidLoad {
[super viewDidLoad];
ViewController *firstVc = [[ViewController alloc] init];
[self addChildVc:firstVc title:@"你好" image:@"mengmeng" selectedImage:@""];
SecondViewController *secondVc = [[SecondViewController alloc] init];
[self addChildVc:secondVc title:@"hello" image:@"jiyi" selectedImage:@""];
}
- (void)addChildVc:(UIViewController *)childVC title:(NSString *)title image:(NSString *)image selectedImage:(NSString *)selectedImage
{
childVC.title = title;//同时设置tabBar和navgationBar的文字
//设置控制器的图片
childVC.tabBarItem.image = [UIImage imageNamed:image];
childVC.tabBarItem.selectedImage = [UIImage imageNamed:selectedImage];
//设置导航控制器
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:childVC];
//添加为子控制器
[self addChildViewController:nav];
}
在AppDelegate中
self.window.rootViewController = [[QZTabBarController alloc] init];
就可以了
边栏推荐
- Stm32+mfrc522 completes IC card number reading, password modification, data reading and writing
- JVM command induction
- CF1481C Fence Painting
- Li Mu D2L (IV) -- softmax regression
- 会议OA项目(三)---我的会议(会议排座、送审)
- 您的登录IP不在管理员配置的登录掩码范围内
- 多层嵌套后的 Fragment 懒加载实现
- Order based evaluation index (especially for recommendation system and multi label learning)
- QT | about how to use EventFilter
- 神经网络与深度学习-6- 支持向量机1 -PyTorch
猜你喜欢
[MySQL] detailed explanation of MySQL lock (III)
Mysql事务
Elastic APM installation and use
What is the difference between NFT and digital collections?
Datax的学习笔记
Voice chat app source code - Nath live broadcast system source code
Exception handling mechanism II
Canal 的学习笔记
Redis principle and use - Basic Features
The essence of attack and defense strategy behind the noun of network security
随机推荐
2022 mobile crane driver test question simulation test question bank simulation test platform operation
Zipkin安装和使用
Personality test system V1.0
Local cache
Windows backs up the database locally by command
[online problem] timeout waiting for connection from pool problem troubleshooting
opencv图像处理
QT | about how to use EventFilter
Vertical search
arcgis的基本使用4
大二上第一周学习笔记
a-table中的rowSelection清空问题
暑假第四周
解决“NOTE: One or more layouts are missing the layout_width or layout_height attributes.”
OFDM 十六讲- OFDM
"Could not build the server_names_hash, you should increase server_names_hash_bucket_size: 32"
The Child and Binary Tree-多项式开根求逆
对象型的集合按某个属性的值进行去重
Error: cannot find module 'UMI' problem handling
JS closure: binding of functions to their lexical environment