Latest 1.2.1
Homepage https://github.com/dkhamsing/DKScrollingTabController
License MIT
Platforms ios 7.0, requires ARC
Authors

A scrolling tab controller alternative to UISegmentedControl.

Build Status
Version
License
Platform

Installation

Manual

Add the files in the DKScrollingTabController folder to your project.

CocoaPods

platform :ios, '8.0'
pod 'DKScrollingTabController'

Usage

Objective-C

#import "DKScrollingTabController.h" 

  // ...

  // 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;

  // ...

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

}

Customization

  • Change the controller’s padding, font, colors and more.
  • Set layoutIsVertical to YES to show the controller vertically.

Demo

DKScrollingTabController includes sample projects in the folders Demo-Objc and Demo-Swift.

Compatibility

This project was tested with iOS 9.

Contact

License

DKScrollingTabController is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "DKScrollingTabController",
    "version": "1.2.1",
    "summary": "Scrolling Tab iOS Control.",
    "description": "A scrolling tab controller alternative to UISegmentedControl.",
    "homepage": "https://github.com/dkhamsing/DKScrollingTabController",
    "screenshots": "https://github.com/dkhamsing/DKScrollingTabController/raw/master/Assets/demo.gif",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "dkhamsing": "[email protected]"
    },
    "social_media_url": "http://twitter.com/dkhamsing",
    "platforms": {
        "ios": "7.0"
    },
    "source": {
        "git": "https://github.com/dkhamsing/DKScrollingTabController.git",
        "tag": "1.2.1"
    },
    "source_files": "DKScrollingTabController/*",
    "requires_arc": true
}

Pin It on Pinterest

Share This