DKScrollingTabController 1.2.1

DKScrollingTabController 1.2.1

测试测试
语言语言 Obj-CObjective C
许可 MIT
发布上次发布2015年10月

Daniel Khamsing 维护。




UISegmentedControl 的滚动标签控制器。

安装

手动安装

将 DKScrollingTabController 文件夹中的文件添加到您的项目中。

使用方法

Objective-C

#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));
}

Swift

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 文件。