. | . |
---|---|
![]() | ![]() |
SimpleTab提供了一种简单的方法来替代默认的UITabBarController,支持以下功能
SimpleTab遵循以下原则开发
包含的示例项目演示了SimpleTab的用法
要运行示例项目,首先克隆仓库,然后在示例目录中运行pod install
。
SimpleTab可以通过CocoaPods获取。要安装它,只需将以下行添加到Podfile中
pod "SimpleTab"
注意:从0.2.0版本开始,SimpleTab现在支持Swift 3.X。
1.0 将SimpleTab框架导入到您的项目中
#import SimpleTab
2.0 如果使用Interface Builder,请确保
SimpleTabBarController
SimpleTabBar
SimpleTabBarItem
3.0 获取Tab Bar Controller的引用,最好在AppDelegate中获取
simpleTBC = self.window!.rootViewController as? SimpleTabBarController
4.0 设置视图过渡
包含的动画
simpleTBC?.viewTransition = PopViewTransition()
5.0 设置Tab Bar样式
包含的样式
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 文件。