https://www.jianshu.com/p/6986edb3f42e
实例:
https://www.cnblogs.com/wendingding/p/3775488.html
//
// ViewController.m
// UITabBarController标签控制器
//
// Created by Liu,Wenbo(TBRD) on 2020/6/2.
// Copyright © 2020 Liu,Wenbo(TBRD). All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
UITabBarController *tabar = [[UITabBarController alloc] init];
UIViewController *c1=[[UIViewController alloc]init];
c1.view.backgroundColor=[UIColor grayColor];
c1.view.backgroundColor=[UIColor greenColor];
c1.tabBarItem.title=@"消息";
c1.tabBarItem.image=[UIImage imageNamed:@"tab_recent_nor"];
c1.tabBarItem.badgeValue=@"123";
UIViewController *c2=[[UIViewController alloc]init];
c2.view.backgroundColor=[UIColor brownColor];
c2.tabBarItem.title=@"联系人";
c2.tabBarItem.image=[UIImage imageNamed:@"tab_buddy_nor"];
//设置系统图标
UITabBarItem *item = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemContacts tag:3];
c2.tabBarItem = item;
UIViewController *c3=[[UIViewController alloc]init];
c3.view.backgroundColor = [UIColor grayColor];
c3.tabBarItem.title=@"动态";
c3.tabBarItem.image=[UIImage imageNamed:@"tab_qworld_nor"];
UIViewController *c4=[[UIViewController alloc]init];
c4.tabBarItem.title=@"设置";
c4.tabBarItem.image=[UIImage imageNamed:@"tab_me_nor"];
UIViewController *c5 = [[UIViewController alloc] init];
c5.tabBarItem.title = @"其他";
c5.view.backgroundColor = [UIColor yellowColor];
//大于5个标签会自动出现一个more按钮
UIViewController *c6 = [[UIViewController alloc] init];
c6.tabBarItem.title = @"更多";
c6.view.backgroundColor = [UIColor greenColor];
tabar.viewControllers = @[c1,c2,c3,c4,c5,c6];
[self presentViewController:tabar animated:YES completion:nil];
}
@end