tabbar代码加载。设置tabbaritem的title和image

本文介绍如何在iOS应用中使用Objective-C初始化并配置UITabBarController及其子视图控制器,包括设置标题、图标及选择默认显示的视图。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

   rootViewController = [[UITabBarController alloc] init];
    
    //初始化tabBar上面的所有视图控制器
    picker1Controller = [[Picker1ViewController alloc] init];
    picker2Controller = [[Picker2ViewController alloc] init];

    [picker1Controller.tabBarItem initWithTitle:@"pick1" image:[UIImage imageNamed:@"pick1.png"] tag:1];
    [picker2Controller.tabBarItem initWithTitle:@"pick2" image:[UIImage imageNamed:@"pick2.png"] tag:2];
    这样连图片都有了
    但是图片得是30*30的

    controllersOfTabBar = [[NSMutableArray alloc] init];
    [controllersOfTabBar addObject:picker1Controller];
    [controllersOfTabBar addObject:picker2Controller];
    
    rootViewController.viewControllers = controllersOfTabBar;
    rootViewController.selectedViewController = picker1Controller;
    
    [window addSubview:rootViewController.view];
        [window makeKeyAndVisible];
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值