![ESTabBarController](logo.png) [![SwiftPM compatible](https://img.shields.io/badge/SwiftPM-compatible-orange.svg)](#swift-package-manager) [![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![CocoaPods](https://img.shields.io/cocoapods/v/ESTabBarController-swift.svg)](http://cocoapods.org/pods/ESTabBarController-swift) [![Swift v5](https://img.shields.io/badge/Swift-5-orange.svg?style=flat)](https://developer.apple.com/swift/) [![Twitter](https://img.shields.io/badge/Twitter-@lihao_iOS-blue.svg?style=flat)](https://twitter.com/lihao_iOS) [![Twitter](https://img.shields.io/badge/Weibo-@李昊_____-orange.svg?style=flat)](http://weibo.com/5120522686/profile?rightmod=1&wvr=6&mod=personinfo&is_all=1) [![Chat Gitter.im](https://badges.gitter.im/ESTabBarController/Lobby.svg)](https://gitter.im/ESTabBarController/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) ### [For English](README.md) **ESTabBarController**是一个高度自定义的TabBarController组件,继承自UITabBarController。 ### 为什么要使用? 在开发工作中,我们可能会遇到需要自定义UITabBar的情况。例如:改变文字样式、添加一些动画效果、设置一个比默认更大的样式等等,以上需求如果只通过UITabBarItem往往很难实现。 **有了ESTabBarController,你可以轻松地实现这些!** -| 功能 |说明 -------------|-------------|------------- 1| 支持默认样式 | 如果直接使用ESTabBarController进行初始化,你会得到与UITabBarController完全相同的仿系统样式
UITabBarController样式: ![enter image description here](Resources/SystemStyle.png) ESTabBarController仿系统样式: ![enter image description here](Resources/CustomStyle.png) 2| 支持带有"More"的默认样式 | 使用ESTabBarController进行初始化,若item大于最大显示数量则显示"More",样式与UITabBarController一致 带有"More"的UITabBarController样式: ![enter image description here](Resources/SystemMoreStyle.png) 带有"More"的ESTabBarController样式: ![enter image description here](Resources/CustomMoreStyle.png) 3| 支持UITabBarItem和ESTabBarItem混合 | 可以任意设置tabbar的items,支持即包含UITabBarItem,同时也包含ESTabBarItem ESTabBar和UITabBar混合样式: ![enter image description here](Resources/MixtureStyle.png) 带有'More'的ESTabBar和UITabBar混合样式: ![enter image description here](Resources/MixtureMoreStyle.png) 4| 支持UIKit属性 | 支持UITabBarController、UITabBar和UITabBarItem的大部分API属性,使原有代码无需任何修改即可无缝迁移到ESTabBarController 支持UITabBarController的`selectedIndex`属性的实现: ![enter image description here](Resources/SelectIndexCode.png) 5| 支持与UINavigationController任意嵌套 | 通常在使用`UITabBarController`过程中,会存在两种比较常见的层级处理方式: 第一种: ├── UITabBarController └──── UINavigationController └────── UIViewController └──────── SubviewControllers 第二种: ├── UINavigationController └──── UITabBarController └────── UIViewController └──────── SubviewControllers 第一种情况在push子视图的时候需要设置 `hidesBottomBarWhenPushed = true` , 第二种则不需要。 在ESTabBarController中,通过添加Container视图到UITabBar的方式来兼容这两种层级处理方式。 6| 支持自定义 | 使用ESTabBarController可以实现: 1. 自定义选中颜色和样式 ![enter image description here](Resources/CustomSelectStyleGif.gif) 2. 添加选中时的动画效果 ![enter image description here](Resources/CustomSelectAnimateGif.gif) 3. 自定义Item的背景颜色 ![enter image description here](Resources/CustomBackgroundGif.gif) 4. 添加高亮时的动画效果 ![enter image description here](Resources/CustomHighlightGif.gif) 5. 添加一些动画暗示用户点击 ![enter image description here](Resources/CustomImpliesGif.gif) 6. 等等...... 7| 支持自定义按钮大小 支持自定义点击事件 | ESTabBarController支持自定义按钮的大小,你可以轻松定制不规则大小的tab按钮。 **当按钮frame大于TabBar时,通过HitTest方法使其超出TabBar区域点击仍然有效。** 另外,ESTabBarController能够自定义点击事件,并通过一个block回调给上层处理。 中间带有较大按钮样式: ![enter image description here](Resources/CustomStyle2.png) 带有特殊提醒框样式: ![enter image description here](Resources/CustomStyle3.png) 自定义按钮点击事件: ![enter image description here](Resources/CustomHitGif.gif) 8| 支持默认通知样式 | 如果直接使用ESTabBarController进行初始化,你会得到与UITabBarController完全相同的仿系统通知样式 UITabBarController样式: ![enter image description here](Resources/SystemNotificationStyle.png) ESTabBarController仿系统样式: ![enter image description here](Resources/CustomNotificationStyle.png) 9| 支持自定义通知样式 | 使用ESTabBarController可以实现: 1. 自定义提醒动画 ![enter image description here](Resources/CustomNofticationGif.gif) ![enter image description here](Resources/CustomNofticationGif2.gif) 2. 自定义提醒样式 ![enter image description here](Resources/CustomNofticationGif3.gif) 3. 等等...... 10| 支持Lottie | 通过自定义ContentView,能够添加Lottie的LAAnimationView到Item ![enter image description here](Resources/LottieGif.gif) ## 支持环境 * Xcode 8 or later * iOS 8.0 or later * ARC * Swift 5 or later ## Demo 下载后运行ESTabBarControllerExample工程,你可以看到一些使用ESTabBarController实现的自定义TabBar的更多例子。 ## 如何安装 ### CocoaPods ``` ruby pod "ESTabBarController-swift" ``` ### Carthage ```ruby github "eggswift/ESTabBarController" ``` ### 手动安装 ``` ruby git clone https://github.com/eggswift/ESTabBarController.git open ESTabBarController ``` ## 未完成的事 1. Containers的布局方式目前是纯代码布局,使用Autolayout应该会更好。 2. 当存在"More"时,若进行Edit会出现问题。 3. UITabBarItem的部分属性还没有桥接到ESTabBarItem。 4. ~~ESTabBarItemMoreContentView中的"More"图片目前还未设置到framework中,计划将它转化为创建CGBitmap的代码。~~ ## 赞助 您可以通过查看我们的赞助商页面来支持该项目。 只需单击一下即可: