iOS objective-c实现底部导航栏

iOS objective-c实现底部导航栏,第1张

一个有5个ViewController

ViewController.m文件

//
//  ViewController.m
//  haha
//
//  Created by 温国强 on 2022/1/9.
//

#import "ViewController.h"
#import "ViewController2.h"
#import "ViewController3.h"
#import "ViewController4.h"
#import "ViewController5.h"

#import "AppDelegate.h"


@interface ViewController ()



@end

@implementation ViewController
   

 
- (void)viewDidLoad {
    [super viewDidLoad];
   

    self.view.backgroundColor=[UIColor whiteColor];
    [self.tabBar setBarTintColor:[UIColor whiteColor]];
    ViewController2 *vc2=[[ViewController2 alloc]init];
    vc2.view.backgroundColor=[UIColor whiteColor];
    vc2.tabBarItem.image=[UIImage imageNamed:@"index-1.png"];
    vc2.tabBarItem.title=@"首页";
    [self addChildViewController:vc2];
    ViewController3 *vc3=[[ViewController3 alloc]init];
    vc3.view.backgroundColor=[UIColor whiteColor];
    vc3.tabBarItem.image=[UIImage imageNamed:@"index-1.png"];
    vc3.tabBarItem.title=@"求助";

    
    [self addChildViewController:vc3];
    ViewController4 *vc4=[[ViewController4 alloc]init];
    vc4.view.backgroundColor=[UIColor whiteColor];
    vc4.tabBarItem.title=@"消息";
    vc4.tabBarItem.image=[UIImage imageNamed:@"index-1.png"];
    [self addChildViewController:vc4];
    
    ViewController5 *vc5=[[ViewController5 alloc]init];
    vc5.view.backgroundColor=[UIColor whiteColor];
    vc5.tabBarItem.title=@"我";
    vc5.tabBarItem.image=[UIImage imageNamed:@"index-1.png"];
    [self addChildViewController:vc5];
}


@end

ViewController.h文件

//
//  ViewController.h
//  haha
//
//  Created by 温国强 on 2022/1/9.
//

#import 

@interface ViewController : UITabBarController


@end

剩余再写4个ViewController就可以了

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/993607.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)

保存