• RDVTabBarController:一个十分完善的tabBarController,可以自定义角标个数,爽的停不下来。
  • RDVTabBarController地址:RDVTabBarController
  • Demo地址:欢迎Star

说明

  • 此教程是旨在让你快速入手,如需更加深层次的了解,请直接RDVTabBarController地址分析即可;

使用

pod 'RDVTabBarController'

建议直接CocoaPods管理,对CocoaPods有兴趣的童鞋可以戳cocoapods-install-usage

结构

RDVTabBar
@interface RDVTabBar : UIView
RDVTabBarController
@interface RDVTabBarController : UIViewController
RDVTabBarItem
@interface RDVTabBarItem : UIControl

RDVTabBarController Example Usage其实已经很详细了,接下来看初始化

 //VString宏定义,为了就是更好的国际化语言,适配多语言,刚好此Demo也国际化了,可以参看https://github.com/sauchye/dev_notes/issues/4
#define VString(x) NSLocalizedString(x, nil)
- (void)setupViewControllers{
SYFirstViewController *firstVC = [[SYFirstViewController alloc] init];
SYSecondViewController *secondVC = [[SYSecondViewController alloc] init];
SYThirdViewController *thirdVC = [[SYThirdViewController alloc] init];
firstVC.title = VString(@"Home");
secondVC.title = VString(@"Found");
thirdVC.title = VString(@"Me");
self.firstNav = [[SYBaseNavigationController alloc] initWithRootViewController:firstVC];
self.secondNav = [[SYBaseNavigationController alloc] initWithRootViewController:secondVC];
self.thirdNav = [[SYBaseNavigationController alloc] initWithRootViewController:thirdVC];
[self setViewControllers:@[self.firstNav, self.secondNav, self.thirdNav]];
[self customizeTabBarForController];
}
- (void)customizeTabBarForController{

    //tabbar 背景图片 tabbar_background
UIImage *backgroundImage = [UIImage imageNamed:@"tabbar_background"];
//选项卡图片
NSArray *tabBarItemImages;
//这里添加tabBar icon图片
//= @[VString(@"First"), VString(@"Second"),VString(@"Third")]; NSArray *tabBarItemTitles = @[VString(@"Home"), VString(@"Found"), VString(@"Me")];
NSInteger index = 0;
for (RDVTabBarItem *item in [[self tabBar] items])
{
item.titlePositionAdjustment = UIOffsetMake(0, 2.0);
[item setBackgroundSelectedImage:backgroundImage withUnselectedImage:backgroundImage];
UIImage *selectedimage = [UIImage imageNamed:[NSString stringWithFormat:@"%@_selected",[tabBarItemImages objectAtIndex:index]]]; UIImage *unselectedimage = [UIImage imageNamed:[NSString stringWithFormat:@"%@_normal",[tabBarItemImages objectAtIndex:index]]]; [item setFinishedSelectedImage:selectedimage withFinishedUnselectedImage:unselectedimage]; [item setTitle:[tabBarItemTitles objectAtIndex:index]];
item.selectedTitleAttributes = @{
NSFontAttributeName: [UIFont boldSystemFontOfSize:12],
NSForegroundColorAttributeName:kNAVIGATION_BAR_COLOR,
};
item.unselectedTitleAttributes = @{
NSFontAttributeName: [UIFont boldSystemFontOfSize:12],
NSForegroundColorAttributeName:RGB(217, 217, 217),
}; [item setTitle:[tabBarItemTitles objectAtIndex:index]];
index++; }
}

这样你的tabBar基本搭建好了,但是还需要完善一些,比如,角标设置,push隐藏等。

  • Push隐藏tabBar,你只需要这样即可

    - (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [[self rdv_tabBarController] setTabBarHidden:YES animated:YES];
    }
  • 设置角标数

     [[self rdv_tabBarItem] setBadgeValue:@"3"];
  • RDVTabBarControllerDelegate,相信你看就会明白,好的方法命名很重要啊~

    /**
    * Asks the delegate whether the specified view controller should be made active.
    */
    - (BOOL)tabBarController:(RDVTabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController; /**
    * Tells the delegate that the user selected an item in the tab bar.
    */
    - (void)tabBarController:(RDVTabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController;
  • 还有需要多等待你去发现...


结语

RDVTabBarController是一个很棒的第三方tabBarController,值得我们学习和思考。

  • 相比传统第三方,你会发现可以很好的定制角标,这是极好的,当然你也可以自定义;
  • 但是不能定义中间凸起的tabBar,好早之前去哪儿就是中间凸起一个tabBar,不过现在去哪儿也改成传统的tabBar了;

--

本文,由我们 iOS122 的小伙伴 @Sauchye​供稿,更多讨论,参见: http://www.ios122.com/tag/rdvtabbarcontroller/

RDVTabBarController--可自由定制的iOS底部导航控件的更多相关文章

  1. BottomNavigationBar 底部导航控件

    BottomNavigationBar 底部导航控件 属性 说明BottomNavigationBarItem 多个 item,iconSize icon大小currentIndex 默认选中第几个o ...

  2. openlayers4 入门开发系列之地图导航控件篇(附源码下载)

    前言 openlayers4 官网的 api 文档介绍地址 openlayers4 api,里面详细的介绍 openlayers4 各个类的介绍,还有就是在线例子:openlayers4 官网在线例子 ...

  3. 【完全开源】百度地图Web service API C#.NET版,带地图显示控件、导航控件、POI查找控件

    目录 概述 功能 如何使用 参考帮助 概述 源代码主要包含三个项目,BMap.NET.BMap.NET.WindowsForm以及BMap.NET.WinformDemo. BMap.NET 对百度地 ...

  4. 天津政府应急系统之GIS一张图(arcgis api for flex)讲解(四)地图导航控件模块

    config.xml文件的配置如下: <widget left="10" top="50" config="widgets/Navigation ...

  5. 从0到1搭建移动App功能自动化测试平台(2):操作iOS应用的控件

    转自:http://debugtalk.com/post/build-app-automated-test-platform-from-0-to-1-Appium-interrogate-iOS-UI ...

  6. 使用 ViewPager 和 RadioGroup 封装的一个导航控件

    import android.animation.ObjectAnimator; import android.content.Context; import android.graphics.dra ...

  7. 【转】【完全开源】百度地图Web service API C#.NET版,带地图显示控件、导航控件、POI查找控件

    [转][完全开源]百度地图Web service API C#.NET版,带地图显示控件.导航控件.POI查找控件 目录 概述 功能 如何使用 参考帮助 概述 源代码主要包含三个项目,BMap.NET ...

  8. 3ds Max 中的导航控件SteeringWheels入门介绍

    介绍 软件环境:3d Max2015 SteeringWheels 3D导航控件也可以说是“追踪菜单”,通过它们可以使用户从单一的工具访问不同的2D和3D导航工具.SteeringWheels可分成多 ...

  9. 3ds Max 中的导航控件ViewCube入门介绍

    介绍 ViewCube 3D导航控件提供当前方向的视觉反馈,让用户可以调整视图方向以及在标准视图与等距视图间进行切换. 软件环境:3d Max2015 第一步.启动3d Max软件,打开场景文件 Vi ...

随机推荐

  1. 17082 两个有序数序列中找第k小(优先做) O(logn)

    17082 两个有序数序列中找第k小(优先做) 时间限制:1000MS  内存限制:65535K提交次数:0 通过次数:0 题型: 编程题   语言: G++;GCC;VC Description 已 ...

  2. Huawei English Corner

     Keywords  Descriptions  FWIW  For what it's worth(不管结果怎样)  ASAP  As Soon As Possible(尽快)  FYI  For ...

  3. (转)sdd for aix 安装及基本命令

    总结出自多个文件(自己做的项目和网上找的资料) 原文:http://blog.csdn.net/yujin2010good/article/details/11395701 一.sddpcm安装 要安 ...

  4. nexus 私服相关的配置

    1 上传到nexus的配置 1 settings.xml <server> <id>releases</id> <username>admin</ ...

  5. http学习笔记(二):URL和资源

    2.1浏览因特网资源 ------------总结:方案.主机.路径 方案:http,FTP,SMTP等 http(超文本传输协议)是一个基于请求与响应模式的.无状态的.应用层的协议,常基于TCP的连 ...

  6. [Android]对字符串进行MD5加密

    /** * 将字符串转成MD5值 * * @param string * @return */ public static String stringToMD5(String string) { by ...

  7. 如何在smarty模板中执行php代码

    Smarty模板主要的目的是分离逻辑层和表现层,所以在模板中不应该包含逻辑部分,逻辑层也不应该含有HTML.要在模板中插入逻辑程序的这种做法"非常"不被推荐,在你的case中. 如 ...

  8. Java反射机制分析指南

    一.JAVA是动态语言吗? 一般而言,说到动态言,都是指在程序运行时允许改变程序结构或者变量类型,从这个观点看,JAVA和C++一样,都不是动态语言. 但JAVA它却有着一个非常突出的动态相关机制:反 ...

  9. java 模拟实现消费者和生产者问题

    题目要求 用java代码模拟实现:一个人不断往箱子里放苹果,另一个人不断从箱子里取苹果,箱子只能放5个苹果,苹果数量无限.要求不使用java.util.concurrent包中的类. 思路 这道题主要 ...

  10. jQuery的定时执行和延迟执行

    jQuery的定时执行和延迟执行 //延迟执行 setTimeout(function(){ console.log("实战授课,100%就业"); },600); //定时执行 ...