当前位置:网站首页>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];就可以了
边栏推荐
猜你喜欢

李沐d2l(五)---多层感知机

The child and binary tree- open root inversion of polynomials

Elastic APM installation and use

李沐d2l(四)---Softmax回归

Ext4 file system opens dir_ After nlink feature, link_ Use link after count exceeds 65000_ Count=1 means the quantity is unknown

NTT (fast number theory transformation) polynomial inverse 1500 word analysis

js在控制台输出菱形

Innovus is stuck, prompting x error:

redis原理和使用-安装和分布式配置

Your login IP is not within the login mask configured by the administrator
随机推荐
Where are the laravel framework log files stored? How to use it?
el-table的formatter属性的用法
Paper notes: knowledge map kgat (unfinished temporary storage)
NTT (fast number theory transformation) polynomial inverse 1500 word analysis
jvm命令归纳
[MySQL] detailed explanation of redo log, undo log and binlog (4)
Apple generated and verified tokens for PHP
MySQL strengthen knowledge points
语音聊天app源码——钠斯直播系统源码
Cat installation and use
838. Heap sorting
Object type collections are de duplicated according to the value of an attribute
Pat grade a a1013 battle over cities
“could not build the server_names_hash, you should increase server_names_hash_bucket_size: 32” 问题处理
Innovus is stuck, prompting x error:
redis原理和使用-安装和分布式配置
Elastic APM installation and use
PHP 之 Apple生成和验证令牌
分布式跟踪系统选型与实践
Conditions for JVM to trigger minor GC