测试测试 | ✗ |
语言语言 | Obj-CObjective C |
许可 | MIT |
发布上次发布 | 2015年10月 |
由 Daniel Khamsing 维护。
是 UISegmentedControl
的滚动标签控制器。
将 DKScrollingTabController 文件夹中的文件添加到您的项目中。
#import "DKScrollingTabController.h"
- (id)init {
self = [super init];
if (self) {
// Add controller as a child view controller (standard view controller containment)
DKScrollingTabController *tabController = [[DKScrollingTabController alloc] init];
[self addChildViewController:tabController];
[tabController didMoveToParentViewController:self];
[self.view addSubview:tabController.view];
// Customize the tab controller (more options in DKScrollingTabController.h or check the demo)
tabController.view.frame = CGRectMake(0, 20, 320, 40);
tabController.buttonPadding = 23;
tabController.selection = @[@"zero", @"one", @"two", @"three", @"four",];
// Set the delegate (conforms to DKScrollingTabControllerDelegate)
tabController.delegate = self;
}
return self;
}
#pragma mark - DKScrollingTabControllerDelegate
- (void)ScrollingTabController:(DKScrollingTabController *)controller selection:(NSUInteger)selection {
NSLog(@"Selection controller action button with index=%@", @(selection));
}
class ViewController: UIViewController, DKScrollingTabControllerDelegate {
let tabController = DKScrollingTabController()
override func viewDidLoad() {
super.viewDidLoad()
self.addChildViewController(tabController)
tabController.didMoveToParentViewController(self)
self.view.addSubview(tabController.view)
tabController.view.frame = CGRectMake(0, 20, 320, 40)
tabController.buttonPadding = 25
tabController.selection = ["zero", "one", "two", "three", "four"]
tabController.delegate = self
}
func ScrollingTabController(controller: DKScrollingTabController!, selection: UInt) {
print("tapped \(selection) \n")
}
}
layoutIsVertical
设置为 YES 以垂直显示控制器。DKScrollingTabController 包含在 Demo-Objc 和 Demo-Swift 文件夹中的示例项目。
该项目已在 iOS 9 上进行测试。
DKScrollingTabController 在 MIT 许可下可用。有关更多信息,请参阅 LICENSE 文件。