BFPaperTabBarController
iOS UITabBar (控制器) 受 Google 的 Paper Material Design 启发。
关于
现在拥有更平滑的动画和更多的公共属性,便于更轻松地进行自定义!
BFPaperTabBarController 是一个 UITabBarController 的子类,其行为与 Google 的 Material Design Labs 中新的 paper 标签栏非常相似。所有动画都是异步的,在子层上执行。BFPaperTabBarControllers 可以立即使用,具有令人愉悦的默认行为,但它们可以轻松地进行自定义!点击圆圈颜色、背景渐变颜色、点击圆圈直径、下划线颜色和下划线厚度都可以通过公共属性轻松自定义。
默认情况下,BFPaperTabBarControllers 使用“智能颜色”,这会将点击圆圈、背景渐变和下划线栏的颜色匹配到 tabBar.tintColor
的颜色。您可以通过将属性 .usesSmartColor
设置为 NO
来关闭智能颜色。如果您禁用智能颜色,则默认使用灰色来设置点击圆圈和背景颜色渐变。您可以通过以下方式设置自己的颜色:.tapCircleColor
和 .backgroundFadeColor
。注意,设置这些会禁用智能颜色。
更改
请参阅此 CHANGELOG.md。
属性
BOOL usesSmartColor
用于设置智能颜色模式的标志,设置为YES使用智能颜色,设置为NO则使用自定义色彩方案。虽然智能颜色是默认的(usesSmartColor = YES),但自定义也非常酷。
CGFloat touchDownAnimationDuration
用于表示在触摸按下时动画持续时间的CGFLoat,默认值为
0.25f
秒。(加油钢人)
CGFloat touchUpAnimationDuration
用于表示在触摸抬起时动画持续时间的CGFLoat,默认值为
2 * touchDownAnimationDuration
秒。
CGFloat tapCircleDiameterStartValue
用于表示触摸圈开始生成时的直径的CGFLoat,默认值为
5.f
。
CGFloat tapCircleDiameter
表示触摸圈直径的CGFloat值。默认情况下,它将是
MAX(self.frame.width, self.frame.height)
的结果。tapCircleDiameterFull
将计算一个始终填充整个视图的圆形。任何小于或等于tapCircleDiameterFull
的值将使用默认值。另外,还有可用的常量:tapCircleDiameterLarge
、tapCircleDiameterMedium
和tapCircleDiameterSmall
。
CGFloat tapCircleBurstAmount
表示在爆炸触摸圈时应该增加直径多少的CGFloat值。默认值为
40.f
。
UIColor *tapCircleColor
用于显示触摸位置的圆圈的UIColor。注意:设置此值将消除触摸圈“智能色彩”的能力。建议使用小于
1
的Alpha值。
UIColor *backgroundFadeColor
用于将透明背景淡化的UIColor。注意:设置此值将消除背景淡化的“智能色彩”能力。建议使用小于
1
的Alpha值。
BOOL rippleFromTapLocation
将标志设置为
YES
以使触摸圈从触摸点开始涟漪。如果设置为NO
,则触摸圈始终从视图的中心开始涟漪。默认为YES
。
UIColor *underlineColor
用于当前选中标签下方下划线的UIColor。注意:设置此值将消除此下划线的“智能色彩”能力。
CGFloat underlineThickness
用于设置下划线厚度(高度)的CGFLoat。注意:大值会遮挡默认TabBarItem标题的低垂字母底部。
BOOL animateUnderlineBar
表示是否应该动画滑动的布尔标志,在该之下滑动到的标签处。
YES
将使条形滑动到选中标签,NO
将使其立即出现在下面。默认为YES
。
BOOL showUnderline
将标志设置为
YES
以显示跟踪当前选中标签的下划线条。
BOOL showTopLine
将标志设置为
YES
以显示跟踪当前选中标签的上线条。
BOOL showTapCircleAndBackgroundFade
设置此标志为
YES
以显示触摸圈和背景渐变。如果设置为NO
,则它们将不会显示。
BOOL userInteractionEnabled
一个标志,用于启用或禁用栏的触摸手势。当某些内容覆盖标签栏(如全屏弹出窗口)时,将其设置为NO。
函数
(void)selectTabAtIndex:(NSInteger)index animated:(BOOL)animated
选择并突出显示一个标签。
@param index (NSInteger) 您希望选择和突出显示的标签的索引。
@param animated (BOOL) 一个标志,用于确定是否应该动画改变。
待办事项
支持程序化实例化。
使用方法
BFPaperTabBarController 只在 Interface Builder 中受支持。
将 BFPaperTabBarController 的头文件和实现文件添加到您的项目中。(.h & .m)
子类化!
要使用 BFPaperTabBarController,创建一个 UITabBarController 对象并将其父类设置为 BFPaperTabBarController。
@interface MyTabBarController : BFPaperTabBarController
//...
@end
自定义示例
在您的 UITabBarController,它是一个 BFPaperTabBarController 的子类
(直接从示例项目中取出。)
// NOTE: paperColors available from my other library, BFPaperColors :)
self.tabBar.tintColor = [UIColor paperColorDeepPurpleA400]; // set the tab bar tint color to something cool.
self.rippleFromTapLocation = NO; // YES = spawn tap-circles from tap locaiton. NO = spawn tap-circles from the center of the tab.
self.usesSmartColor = NO; // YES = colors are chosen from the tabBar.tintColor. NO = colors will be shades of gray.
self.tapCircleColor = [[UIColor paperColorLightBlue] colorWithAlphaComponent:0.2]; // Set this to customize the tap-circle color.
self.backgroundFadeColor = [UIColor paperColorGreenA400]; // Set this to customize the background fade color.
self.tapCircleDiameter = bfPaperTabBarController_tapCircleDiameterSmall; // Set this to customize the tap-circle diameter.
self.underlineColor = [UIColor paperColorDeepPurpleA400]; // Set this to customize the color of the underline which highlights the currently selected tab.
self.animateUnderlineBar = NO; // YES = bar slides below tabs to the selected one. NO = bar appears below selected tab instantaneously.
self.showUnderline = NO; // YES = show the underline bar, NO = hide the underline bar.
self.underlineThickness = 4.f; // Set this to adjust the thickness (height) of the underline bar. Not that any value greater than 1 could cover up parts of the TabBarItem's title.
self.showTapCircleAndBackgroundFade = NO; // YES = show the tap-circles and add a color fade the background. NO = do not show the tap-circles and background fade.
CocoaPods
CocoaPods 是管理 Objective-C 项目中库依赖的最佳方式。更多信息请访问 https://cocoapods.org.cn
将以下内容添加到您的 podfile 中以将 BFPaperTabBarController 添加到项目中。
platform :ios, '7.0'
pod 'BFPaperTabBarController'
许可证
BFPaperTabBarController 使用 MIT 许可证
请参阅随附的 LICENSE 文件。