RDVTabBarController这个库写得相当不错,所以今天就简单介绍下它的基本使用,看里面可以清楚的知道代码规范的重要性,这个库的使用方法和官方的相识

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

首先写过控制器继承  RDVTabBarController,

AppDelegate里面的不多说

例如

 self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

 RDVViewController *rootViewController = [[RDVViewController alloc] init];
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];

然后在

RDVViewController.m文件里

为了防止tabbar的双点击事件,设置代理<RDVTabBarControllerDelegate>,添加标示,用在点击事件

要设置tabbaritem的字体和图片,需导入文件

#import "RDVTabBarItem.h"

 #import "RDVViewController.h"
#import "ViewController.h"
#import "RDVTabBarItem.h" @interface RDVViewController ()<RDVTabBarControllerDelegate>
{
NSInteger selectedTabBarIiemTag;
}
@end @implementation RDVViewController - (void)viewDidLoad {
[super viewDidLoad]; ViewController *homeView=[[ViewController alloc]init];
UINavigationController *NAV1 = [[UINavigationController alloc] initWithRootViewController:homeView]; ViewController *View=[[ViewController alloc]init];
UINavigationController *NAV2 = [[UINavigationController alloc] initWithRootViewController:View]; ViewController *home=[[ViewController alloc]init];
UINavigationController *NAV3 = [[UINavigationController alloc] initWithRootViewController:home]; self.viewControllers = @[NAV1,NAV2,NAV3];
[self customizeTabBarForController:self];
self.delegate = self;
} - (void)customizeTabBarForController:(RDVTabBarController *)tabBarController { NSArray *tabBarItemImages = @[@"首页select", @"首页select",@"首页select"]; NSInteger index = ;
for (RDVTabBarItem *tabberItem in [[tabBarController tabBar] items]) { tabberItem.title = [NSString stringWithFormat:@"%ld",index+]; NSDictionary *tabBarTitleUnselectedDic = @{NSForegroundColorAttributeName:[UIColor blackColor],NSFontAttributeName:[UIFont systemFontOfSize:]};
NSDictionary *tabBarTitleSelectedDic = @{NSForegroundColorAttributeName:[UIColor blueColor],NSFontAttributeName:[UIFont systemFontOfSize:]};
//修改tabberItem的title颜色
tabberItem.selectedTitleAttributes = tabBarTitleSelectedDic;
tabberItem.unselectedTitleAttributes = tabBarTitleUnselectedDic;
tabberItem.tag = +index;
UIImage *selectedimage = [UIImage imageNamed:@"首页"];
UIImage *unselectedimage = [UIImage imageNamed:[NSString stringWithFormat:@"%@",
[tabBarItemImages objectAtIndex:index]]];
//设置tabberItem的选中和未选中图片
[tabberItem setFinishedSelectedImage:selectedimage withFinishedUnselectedImage:unselectedimage]; index++;
}
}

上面就满足基本使用方法了,为了防止双点击事件,已经设置了代理和tag值

这里的item不是tabbaritem,而是  rdv_tabBarItem,如果使用了tabBarItem的tag值,那是不存在的,因为这里设置的是rdv的tabBarItem

 #pragma mark - 防止tabbar双击
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController { if(selectedTabBarIiemTag == viewController.rdv_tabBarItem.tag){ return NO; }else { selectedTabBarIiemTag = viewController.rdv_tabBarItem.tag;
return YES; }
}

RDVTabBarController的基本使用 以及tabbar的防止双点击方法的更多相关文章

  1. 重复点击主界面(TabBar)按钮刷新界面--点击状态栏回到顶部

    1.监听按钮点击   2.判断是否是点击的同一个按钮(记录上次点击的按钮)   3.当重复点击相同按钮时,需要获取当前按钮对应控制器刷新界面      3.1 判断是否重复点击按钮,代码写在哪里?   ...

  2. iOS自定制tabbar与系统的tabbar冲突,造成第一次点击各个item图片更换选中,第二次选中部分item图片不改变

    可以选择是使用自定制的还是系统的,如果使用自定制的,就使用以下方法即可隐藏系统的uitabbarButton,从而使item恢复正确 //隐藏UITabBarButton -(void)viewWil ...

  3. 使用 RDVTabBarController 制作底部凸起的 TabBar 笔记

    欢迎訪问我的个人博客http://mmoaay.photo/ 本文主要针对底部凸起的 TabBar 这样的特殊需求,不感兴趣的能够直接绕过- 近期做的一个项目须要底部凸起的 TabBar,效果例如以下 ...

  4. react-native的tabbar和navigator混合使用

    前段时间搭建项目使用了navigator和react-native-tab-navigator,现在我教大家搭建一个通用的简单框架. 先把几张图贴在这里,这就是我们今天要搭建的东西,别看页面简单,但是 ...

  5. Swift开发小技巧--TabBar中间按钮的添加方案

    TabBar中间按钮的添加方案 之前做百思项目的时候,也有一个中间按钮,当时是重写的TabBar,这里介绍一个新的方法 给TabbarVC多添加添加一个控制器,这个控制器的作用仅仅是用来占位的,多了这 ...

  6. [iOS微博项目 - 1.6] - 自定义TabBar

    A.自定义TabBar 1.需求 控制TabBar内的item的文本颜色(普通状态.被选中状态要和图标一致).背景(普通状态.被选中状态均为透明) 重新设置TabBar内的item位置,为下一步在Ta ...

  7. iOS 屏幕旋转 nav+tabbar+present(网页) 2016

    如题,最近一个app架构为 nav + tabbar ,需求是 在点击tabbar中的一个菜单项时,弹出网页,该网页需要横屏显示,其他页面不变  都保持竖屏. XCode Version 7.2.1 ...

  8. iOS 开源一个高度可定制支持各种动画效果,支持单击双击,小红点,支持自定义不规则按钮的tabbar

    TYTabbarAnimationDemo 业务需求导致需要做一个tabbar,里面的按钮点击带有动画效果,tabbar中间的按钮凸出,凸出部分可以点击,支持badge 小红点等,为此封装了一个高度可 ...

  9. (六十三)自定义TabBar和TabBarButtonItem

    自定义TabBar 先自定义一个UITabBarController,为了方便跳转与设定属性,借助系统的TabBarController的功能,但是要移除内部的控件然后自己添加一个View和多个按钮. ...

随机推荐

  1. 基于git的源代码管理模型——git flow

    基于git的源代码管理模型--git flow A successful Git branching model

  2. SQL--存储过程

    声明和调用有返回值的存储过程 分页存储过程 转账的存储过程:

  3. [Asp.net]通过uploadify将文件上传到B服务器的共享文件夹中

    写在前面 客户有这样的一个需求,针对项目中文档共享的模块,客户提出如果用户上传特别的大,或者时间久了硬盘空间就会吃满,能不能将这些文件上传到其他的服务器?然后就稍微研究了下这方面的东西,上传到网络中的 ...

  4. ASP.NET MVC PartialView用法

    子页面AreaSelect.cshtml页面的Controller代码: public ActionResult AreaSelect() { return PartialView(); } 父页面前 ...

  5. 【iOS】关联属性存取数据

    有时候我们需要在现有的类存放一些额外的信息,通常的做法是继承一个子类,然后定义新增加的属性,然而如果我们为每个需要的类都添加一个类显得太麻烦了,objc提供了一个关联属性的特性,可以给一个对象关联一个 ...

  6. C# ~ 由 IDisposable 到 GC

    IDisposable 接口 1. 托管资源和非托管资源   ·  托管资源  a.  CLR 控制和管理的内存资源,如程序中在 Heap 上分配的对象.作用域内的变量等:  b.  GC 机制实现自 ...

  7. ASP.NET MVC SSO单点登录设计与实现(转载)

    实验环境配置 HOST文件配置如下: 127.0.0.1 app.com127.0.0.1 sso.com IIS配置如下: 应用程序池采用.Net Framework 4.0 注意IIS绑定的域名, ...

  8. C++学习笔记13:运算符重载(赋值操作符2)

    移动语义 完成所有权的移交,当拷贝构造和赋值构造时,目标对象的所有权必须移交给我们的新的对象,原始对象将丧失所有权,_p指针将不再指向原来的那个数组: 左值与右值 C原始定义 左值:可以出现在赋值号的 ...

  9. 2016 年沈阳网络赛---QSC and Master(区间DP)

    题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=5900 Problem Description Every school has some legend ...

  10. 框架Spring笔记系列 一 基础

    主题:Spring 1.什么样的问题,使得Spring框架应用而生?使用Spring解决了那些问题? 2.