iOS RDVTabBarController

本文介绍了一个名为RDVTabBarController的库,它提供了一种简单的方法来实现iOS应用中不同页面间的切换以及TabBar的自定义功能。通过初始化多个ViewController并设置为TabBarController的子视图控制器,用户可以轻松地在不同页面之间进行导航。同时,库还支持TabBar的隐藏与显示,以及自定义字体颜色,极大地提高了用户体验。

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

前段时间接触到这个库,感觉还不错!用的也挺多。

效果图如下:

RDVTabBarController

功能简介:
第一个页面:点击后下标显示对应的数字
第二个页面:点击后 隐藏/显示 TabBar
第三个页面:点击后隐藏 TabBar, 并跳转到其他页面;再点击返回按钮时返回,并显示 TabBar.

github 地址:https://github.com/robbdimitrov/RDVTabBarController

  • 初始化 ViewController:
UIViewController *firstViewController = [[RDVFirstViewController alloc] init];
UIViewController *firstNavigationController = [[UINavigationController alloc]
                                                   initWithRootViewController:firstViewController];

UIViewController *secondViewController = [[RDVSecondViewController alloc] init];
UIViewController *secondNavigationController = [[UINavigationController alloc]
                                                  initWithRootViewController:secondViewController];

UIViewController *thirdViewController = [[RDVThirdViewController alloc] init];
UIViewController *thirdNavigationController = [[UINavigationController alloc]
                                                   initWithRootViewController:thirdViewController];

RDVTabBarController *tabBarController = [[RDVTabBarController alloc] init];
[tabBarController setViewControllers:@[firstNavigationController, secondNavigationController,
                                           thirdNavigationController]]; // 添加3个ViewController
self.viewController = tabBarController;
  • 页面之间跳转时显示/隐藏 TabBar
// 隐藏 TabBar
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [[self rdv_tabBarController] setTabBarHidden:YES animated:YES];
}
// 显示 TabBar
-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [[self rdv_tabBarController]setTabBarHidden:NO animated:YES];
}
  • 自定义 TabBar 字体颜色
NSDictionary *selectedFontColor = @{
                                   NSFontAttributeName: [UIFont systemFontOfSize:12],
                                   NSForegroundColorAttributeName: [UIColor redColor],
                                   };

NSDictionary *unSelectedFontColor = @{
                                   NSFontAttributeName: [UIFont systemFontOfSize:12],
                                   NSForegroundColorAttributeName: [UIColor blackColor],
                                   };
item.selectedTitleAttributes = selectedFontColor;
item.unselectedTitleAttributes = unSelectedFontColor;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值