SimpleTab 0.2.1

SimpleTab 0.2.1

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布最后发布2017年6月
SwiftSwift版本3.0
SPM支持SPM

azfx维护。



SimpleTab 0.2.1

  • azfx

image

关于

. .
image image

SimpleTab提供了一种简单的方法来替代默认的UITabBarController,支持以下功能

  • 自定义Tab栏项的UI
  • 自定义Tab切换时的动画效果
  • 自定义Tab切换时的视图过渡

SimpleTab遵循以下原则开发

  • 简单 - 易于使用,易回退
  • 保持车轮 - 利用UITabBarController的核心功能
  • 灵活 - 提供钩子以自定义UI和动画

演示

包含的示例项目演示了SimpleTab的用法

要运行示例项目,首先克隆仓库,然后在示例目录中运行pod install

要求

  • iOS 8.0+
  • ARC

安装

SimpleTab可以通过CocoaPods获取。要安装它,只需将以下行添加到Podfile中

pod "SimpleTab"

注意:从0.2.0版本开始,SimpleTab现在支持Swift 3.X。

入门

1.0 将SimpleTab框架导入到您的项目中

#import SimpleTab

2.0 如果使用Interface Builder,请确保

  • Tab Bar Controller设置为SimpleTabBarController
  • Tab Bar设置为SimpleTabBar
  • Tab Bar Item设置为SimpleTabBarItem

3.0 获取Tab Bar Controller的引用,最好在AppDelegate中获取

simpleTBC = self.window!.rootViewController as? SimpleTabBarController

4.0 设置视图过渡

包含的动画

  • PopViewTransition
  • CrossFadeTransition
simpleTBC?.viewTransition = PopViewTransition()

5.0 设置Tab Bar样式

包含的样式

  • PopTabBarStyle
  • ElegantTabBarStyle
var style:SimpleTabBarStyle = PopTabBarStyle(tabBar: simpleTBC!.tabBar)

5.1 可选 - 设置选中状态和未选中状态(正常状态)的Tab标题属性。
或使用Interface Builder中的Tint Color设置状态

style.setTitleTextAttributes([NSFontAttributeName : UIFont.systemFontOfSize(14),  NSForegroundColorAttributeName: UIColor.lightGrayColor()], forState: .Normal)
style.setTitleTextAttributes([NSFontAttributeName : UIFont.systemFontOfSize(14),NSForegroundColorAttributeName: colorWithHexString("4CB6BE")], forState: .Selected)

5.2 可选 - 设置选中状态和未选中状态(正常状态)的Tab图标颜色。
或使用应用的主题颜色设置状态

style.setIconColor(UIColor.lightGrayColor(), forState: UIControlState.Normal)
style.setIconColor(UIColor.blueColor(), forState: UIControlState.Selected)

6.0 最后,让Tab Bar Controller知道正在使用的样式

simpleTBC?.tabBarStyle = style

定制

自定义设置

作者

azfx, [email protected]

许可证

SimpleTab 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。