FBTabBarController
FBTabBarController 是一个易于使用的 UITabBarController,可以使任何应用的标签页面看起来像 Facebook iOS 应用。无需在自定义标签栏中挣扎以实现浮动平台指示器。只需使用这个库就可以快速将您的项目启动起来!
Facebook iOS 应用
查看 Georgia Tech Hockey App 中 FBTabBarController 的使用情况
安装
CocoaPod
- 在 Podfile 中添加一个 pod 键入口
pod 'FBTabBarController'- 通过运行以下命令更新您的 Podfile
pod update- 别忘了在您的目标类中包含必要的导入语句
import FBTabBarController本地
-
在您的项目中您希望的文件夹内创建一个新的文件
-
将 FBTabBarController.swift 的内容复制到您的本地文件。
开发
设置和使用方式与处理普通 UITabBarController 非常相似。以下是最简单的设置形式:
let fbTabBarController = FBTabBarController()
let firstViewController = FirstViewController()
firstViewController.tabBarItem = FBTabBarItem(title: "First",
image: UIImage(systemName: "1.circle.fill"),
tag: 0)
let secondViewController = SecondViewController()
secondViewController.tabBarItem = FBTabBarItem(title: "Second",
image: UIImage(systemName: "2.circle.fill"),
tag: 1)
let thirdViewController = ThirdViewController()
thirdViewController.tabBarItem = FBTabBarItem(title: "Third",
image: UIImage(systemName: "3.circle.fill"),
tag: 2)
fbTabBarController.setViewControllers([firstViewController, secondViewController, thirdViewController], animated: true)有几种方法可以自定义 FBTabBarController 的颜色。
1. 通过设置 fbTabBarController 的 tintColor 来为所有标签设置一种颜色
fbTabBarController.tabBar.tintColor = .systemRed2. 通过设置 FBTabBarItem 的 tintColor 为每个特定的标签设置一种颜色
firstViewController.tabBarItem = FBTabBarItem(title: "First",
image: UIImage(systemName: "1.circle.fill"),
tag: 0,
tintColor: .systemBlue)您可以根据需要添加或减少自定义项。
需要 iOS 13.0 或更高版本。
请查看 FBTabBarControllerExample 获取一个可工作的项目。
想要贡献?
这是一个开源项目,欢迎任何新增功能、修复或有趣的新想法!如果您有兴趣为 FBTabBarController 贡献代码,请确保创建了您自己的仓库分支,完成后提交拉取请求。
许可证
MIT



