ESTabBarController
是一个用于 iOS 的自定义标签栏控制器。当在标签之间切换时,它有一个在标签栏上移动的动画标签指示器。它还提供了运行与标签栏按钮关联的操作的能力。
兼容 iOS 7.0 及以上版本。
简单地将 ESTabBarController
添加到您的 Podfile
中
pod 'ESTabBarController'
ESTabBarController
使用表示标签栏按钮图标的图像数组进行初始化
ESTabBarController *tabBarController = [[ESTabBarController alloc] initWithTabIcons:@[[UIImage imageNamed:@"firstIcon"],
[UIImage imageNamed:@"secondIcon"],
[UIImage imageNamed:@"thirdIcon"]]];
如果所有图像都从主包中加载,则可以使用便利初始化器
ESTabBarController *tabBarController = [[ESTabBarController alloc] initWithTabIconNames:@[@"firstIcon", @"secondIcon", @"thirdIcon"]];
以这种方式设置视图控制器
[tabBarController setViewController:myFirstViewController
atIndex:0];
[tabBarController setViewController:mySecondViewController
atIndex:2];
请注意,您可能已经有了一个没有关联视图控制器的索引。这在使用一个执行操作但不切换到视图控制器的按钮时可能很有用。
ESTabBarController
允许在按标签栏中的按钮时执行操作
[tabBarController setAction:^{
// Perform an action.
} atIndex:1];
如果还存在与操作索引相关联的控制器,则在切换到该控制器后立即执行此操作。
ESTabBarController
允许有突出显示的按钮。这些按钮以不同的方式显示,在尝试给视图控制器或操作更多重要性时很有用。
[tabBarController highlightButtonAtIndex:1];
ESTabBarController
提供了一种自定义两种颜色的方法
tabBarController.selectedColor = [UIColor redColor]; // Any color.
tabBarController.buttonBackgroundColor = [UIColor grayColor]; // Any color.
有关更多信息,请参阅示例项目。
此库可在 MIT 许可证 下使用。