UITabBarController的简单使用和属性方法总结

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

在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值