[翻译] NMBottomTabBarController

简介:

NMBottomTabBarController

A customisable tab bar controller for iOS written in Objective C. It uses auto layout.

一个自定义的Tabbar控制器,使用了自动布局。

 

Requirements

  1. iOS 7.1 +
  2. ARC
Image Requirements for configuring the tab bar items
  1. Icon image  图标文件
  2. Selected and unselected background image  选中状态和未选中状态的背景图

 

Features

  1. Uses autolayout 使用了自动布局
  2. You can set custom background images, icons and text( custom font and colour) for selected, unselected states of the tabs. 你可以使用自定义的背景图,图标,文本(包括字体颜色以及颜色)的选中和未选中状态值
  3. There are two configurations for the arrangement of text and icon image (Text to the right of icon image and text to the bottom of icon image)  有两种关于文本和图片的配置(图片在左文本在右或者图片在下文本在上)
  4. You can assign controllers for each of the tabs. 你可以给每一个tab设置一个控制器
  5. NMBottomTabBarController will take care of the switching and displaying of the controller views when user switches the tabs. NMBottomTabBarController会处理好控制器的切换操作
  6. In addition the tabs can be switched programatically as required. tabs会自动切换,所以不用你担心什么

 

Installation

  1. Please Download the source files 先下载文件
  2. Drag and drop the NMBottomTabBarController folder into your project 将NMBottomTabBarController文件夹拖到你的项目当中
  3. Include objective-c #import "NMBottomTabBarController.h" wherever necessary 在需要的地方引入头文件NMBottomTabBarController.h

 

Usage

Add a controller and change its custom class to NMBottomTabBarController.

添加一个控制器,然后让他继承自NMBottomTabBarController。

From the controller where you want to display the tab bar controller you can do the initial set up.

然后在你的控制器中进行初始化。

To add a set of controllers that the tab bar controller manages
UIViewController *oneController = [UIViewController new];
oneController.view.backgroundColor = [UIColor greenColor];
UIViewController *twoController = [UIViewController new];
twoController.view.backgroundColor = [UIColor blueColor];
UIViewController *threeController = [UIViewController new]; threeController.view.backgroundColor = [UIColor purpleColor]; UIViewController *fourController = [UIViewController new]; fourController.view.backgroundColor = [UIColor orangeColor]; NMBottomTabBarController *tabBarController = (NMBottomTabBarController *)self.window.rootViewController; tabBarController.controllers = [NSArray arrayWithObjects:oneController,twoController,threeController,fourController, nil];
To set the separator image used between tabs
 tabBarController.tabBar.separatorImage = [UIImage imageNamed:@"separator.jpg"];
Title and Text Orientation

There are two title and text orientations

有两种文本显示方式:

  1. kTitleToRightOfIcon - Places title to the right of the icon image 标题在右图标在左
  2. kTItleToBottomOfIcon - Places title to the nottom of the icon image You can learn how to set these in the next step 标题在下图标在上
To set custom background images, icon, title text and title text orientation
 [tabBarController.tabBar configureTabAtIndex:0 andTitleOrientation :kTitleToRightOfIcon withUnselectedBackgroundImage:[UIImage imageNamed:@"unselected.jpeg"] selectedBackgroundImage:[UIImage imageNamed:@"selected.jpeg"] iconImage:[UIImage imageNamed:@"home"] andText:@"Home"andTextFont:[UIFont systemFontOfSize:12.0] andFontColour:[UIColor whiteColor]];
To select a particular tab programatically
 [tabBarController selectTabAtIndex:0];
Delegates

There are two delegates available for NMBottomTabBarController

NMBottomTabBarController提供两个代理方法:

-(BOOL)shouldSelectTabAtIndex : (NSInteger)index;

It can be used to determine whether to allow the selection of a particular tab

这个可以用来决定是否允许某个tab被选中:

-(void)didSelectTabAtIndex : (NSInteger)index;

It can be used to perform any action once a tab is selected

这个可以用来执行任何的操作,当某个tab被选中的时候

 

To Do

  1. Set selected and unselected attributed text, icon images 设置选中与未选中状态的富文本
  2. Add a more button and display the controllers on next page when the tabs exceed a certain limit. 添加一个按钮,在另外的一个控制器中显示tab。

 

License

The project is licensed under the MIT license. For more information please see the [LICENSE][https://github.com/priankaliz/NMBottomTabBarController/blob/master/LICENSE] file

 

Credits

NMBottomTabBarController was developed for a project I work on. Please feel free to reach me atpriankaliz@gmail.com

目录
相关文章
|
11月前
|
设计模式 算法 搜索推荐
后端开发中的设计模式应用与实践
在软件开发的广袤天地中,后端技术如同构筑高楼大厦的钢筋水泥,支撑起整个应用程序的骨架。本文旨在通过深入浅出的方式,探讨后端开发领域内不可或缺的设计模式,这些模式犹如精雕细琢的工具箱,能够助力开发者打造出既健壮又灵活的系统架构。从单例模式到工厂模式,从观察者模式到策略模式,每一种设计模式都蕴含着深刻的哲理与实践价值,它们不仅仅是代码的组织方式,更是解决复杂问题的智慧结晶。
|
8月前
|
存储 人工智能 图计算
MiniRAG:迷你 RAG 系统加成小型语言模型,爆发出与大型语言模型相当的性能
MiniRAG 是香港大学推出的新型 RAG 系统,专为资源受限场景设计,支持高效知识检索与推理,适用于多种应用场景。
435 12
MiniRAG:迷你 RAG 系统加成小型语言模型,爆发出与大型语言模型相当的性能
|
存储 Cloud Native 数据挖掘
Ganos
Ganos
334 3
|
编解码 人工智能 算法
社区供稿 | AIGC图像分辨率太低?快来试试像素感知扩散超分模型,你想要的细节都在这里!
本文介绍了一种全新的基于SD生成先验的图像超分辨率和修复算法,在多个任务上都有着SOTA的表现。
|
监控 jenkins 测试技术
持续集成/持续部署(CI/CD)的最佳实践
【6月更文挑战第19天】CI/CD最佳实践概括: 确定CI(集成早期发现错误)和CD(自动化部署)概念,选择适配团队的工具如Jenkins、GitLab CI;编写自动化测试,确保每次提交时运行;实行代码审查和质量检查;自动化构建与部署,利用容器技术;建立监控与反馈机制,快速响应问题;采用分支策略如特性分支和拉取请求;持续学习与改进流程,优化效率和质量。
|
数据可视化
RNAseq|构建预后模型后你还需要这些图,森林图,诺莫图,校准曲线,DCA决策曲线
RNAseq|构建预后模型后你还需要这些图,森林图,诺莫图,校准曲线,DCA决策曲线
536 0
|
算法 计算机视觉
【Qt&OpenCV 图像的感兴趣区域ROI】
【Qt&OpenCV 图像的感兴趣区域ROI】
534 1
|
弹性计算 关系型数据库 MySQL
在云服务器ECS上搭建个人网站
本实验帮助您快速了解云上应用的构建方式,同时通过您可以采取的工具、方法和可操作步骤,以帮助您了解如何便捷的搭建属于自己的云上应用。
R语言分析蛋白质组学数据:飞行时间质谱(MALDI-TOF)法、峰值检测、多光谱比较
R语言分析蛋白质组学数据:飞行时间质谱(MALDI-TOF)法、峰值检测、多光谱比较
|
设计模式 数据安全/隐私保护
高效接入第三方登录且易扩展的方法
我们使用适配模式来实现一个实际的业务场景,解决实际问题。年纪稍微大一点的小伙伴一定经历过这样的过程。很早以前开发的老系统应该都有登录接口,但是随着业务的发展和社会的进步,单纯地依赖用户名密码登录显然不能满足用户需求。现在,大部分系统都已经支持多种登录方式,如QQ登录、微信登录、手机登录、微博登录等,同时保留用户名密码的登录方式。虽然登录形式丰富,但是登录后的处理逻辑可以不必改,都是将登录状态保存到Session,遵循开闭原则。首先创建统一的返回结果ResultMsg类。
283 0