[翻译] 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

目录
相关文章
|
前端开发 Serverless UED
iconfont渐变色实现方案总结
iconfont渐变色实现方案总结
945 0
|
设计模式 算法 搜索推荐
后端开发中的设计模式应用与实践
在软件开发的广袤天地中,后端技术如同构筑高楼大厦的钢筋水泥,支撑起整个应用程序的骨架。本文旨在通过深入浅出的方式,探讨后端开发领域内不可或缺的设计模式,这些模式犹如精雕细琢的工具箱,能够助力开发者打造出既健壮又灵活的系统架构。从单例模式到工厂模式,从观察者模式到策略模式,每一种设计模式都蕴含着深刻的哲理与实践价值,它们不仅仅是代码的组织方式,更是解决复杂问题的智慧结晶。
|
11月前
|
设计模式 缓存 应用服务中间件
「全网最细 + 实战源码案例」设计模式——外观模式
外观模式(Facade Pattern)是一种结构型设计模式,旨在为复杂的子系统提供一个统一且简化的接口。通过封装多个子系统的复杂性,外观模式使外部调用更加简单、易用。例如,在智能家居系统中,外观类可以同时控制空调、灯光和电视的开关,而用户只需发出一个指令即可。
295 69
|
iOS开发 开发者 MacOS
深入探索iOS开发中的SwiftUI框架
【10月更文挑战第21天】 本文将带领读者深入了解Apple最新推出的SwiftUI框架,这一革命性的用户界面构建工具为iOS开发者提供了一种声明式、高效且直观的方式来创建复杂的用户界面。通过分析SwiftUI的核心概念、主要特性以及在实际项目中的应用示例,我们将展示如何利用SwiftUI简化UI代码,提高开发效率,并保持应用程序的高性能和响应性。无论你是iOS开发的新手还是有经验的开发者,本文都将为你提供宝贵的见解和实用的指导。
339 66
|
存储 Cloud Native 数据挖掘
Ganos
Ganos
413 3
|
iOS开发
我给 iOS 系统打了个补丁——修复 iOS 16 系统键盘重大 Crash(下)
我给 iOS 系统打了个补丁——修复 iOS 16 系统键盘重大 Crash(下)
828 1
|
编解码 人工智能 算法
社区供稿 | AIGC图像分辨率太低?快来试试像素感知扩散超分模型,你想要的细节都在这里!
本文介绍了一种全新的基于SD生成先验的图像超分辨率和修复算法,在多个任务上都有着SOTA的表现。
|
缓存 NoSQL Java
个人项目中技术落地的基础入门(1)
个人项目中技术落地的基础入门
345 6
|
存储 运维 架构师
架构之道:人人都是架构师(1)
架构之道:人人都是架构师
583 8
|
缓存 移动开发 监控
淘宝页面首帧优化的经验和心得
淘宝页面首帧优化的经验和心得
617 9