测试测试过的 | ✗ |
语言语言 | Obj-CObjective C |
许可证 | MIT |
发布上次发布 | 2015年6月 |
由 David Cortés 维护。
LFSSegmentedBarController 是一个受 Android 标签栏启发的 iOS 全自定义标签栏。它支持在标签上点击手势和标签之间的滚动。
LFSSegmentedBarController 受到原生 iOS SDK 中的 UITabBarController 的启发。您可以在下面看到一个使用此控制器的示例。
LFSSegmentedBarController *tabBarController = [[LFSSegmentedBarController alloc] init];
// We setup all the view controller that will be inside our tab bar controller
FirstViewController *firstViewController = [[FirstViewController alloc] initWithNibName:NSStringFromClass([FirstViewController class]) bundle:nil];
LFSSegmentedBarItem *firstBarItem = [[LFSSegmentedBarItem alloc] initWithTitle:NSLocalizedString(@"Tab 1", nil)];
[firstViewController setSegmentedBarItem:firstBarItem];
SecondViewController *secondViewController = [[SecondViewController alloc] initWithNibName:NSStringFromClass([SecondViewController class]) bundle:nil];
LFSSegmentedBarItem *secondBarItem = [[LFSSegmentedBarItem alloc] initWithTitle:NSLocalizedString(@"Tab 2", nil)];
[secondViewController setSegmentedBarItem:secondBarItem];
ThirdViewController *thirdViewController = [[ThirdViewController alloc] initWithNibName:NSStringFromClass([ThirdViewController class]) bundle:nil];
LFSSegmentedBarItem *thirdBarItem = [[LFSSegmentedBarItem alloc] initWithTitle:NSLocalizedString(@"Tab 3", nil)];
[thirdViewController setSegmentedBarItem:thirdBarItem];
// Setting the view controller will configure all the tab bar properties
[tabBarController setViewControllers:@[firstViewController, secondViewController, thirdViewController]];
[self.window setRootViewController:tabBarController];
以下是在 LFSSegmentedBarController 中可自定义的字段示例
LFSSegmentedBarController *tabBarController = [[LFSSegmentedBarController alloc] init];
// Font customizations
[tabBarController setFont:[UIFont systemFontOfSize:17.0]];
[tabBarController setSelectedFont:[UIFont boldSystemFontOfSize:17.0]];
// Line colors and heights
[tabBarController.segmentedControl setHighlightLineHeight:3.0f];
[tabBarController.segmentedControl setLineTintColor:[UIColor whiteColor]];
[tabBarController.segmentedControl setSelectedSectionLineTintColor:[UIColor colorWithRed:0.15f green:0.67f blue:0.86f alpha:1]];
// Text colors
[tabBarController.segmentedControl setTextColor:[UIColor colorWithWhite:0.0f alpha:0.9f]];
[tabBarController.segmentedControl setSelectedTextColor:[UIColor colorWithWhite:0.0f alpha:0.9f]];
// Showing or not showing separator line
[tabBarController.segmentedControl setShowFullWithLine:NO];