Latest 0.1.8
Homepage https://github.com/tayhalla/THSegmentedControl
License MIT
Platforms ios 5.0, requires ARC
Authors

demo

THSegmentedControl is a direct subclass of UIResponder and mimics the current functionality of UISegmentedControl with the added benefit of being able to perform multiple selection.

Usage

Alloc/Init it just like you would a normal UISegmentedControl:

NSArray *segments = @[@"White", @"Black", @"Gold"];
THSegmentedControl *thControl = [[THSegmentedControl alloc] initWithSegments:segments];

// OR

NSArray *segments = @[@"White", @"Black", @"Gold"];
THSegmentedControl *thControl = [[THSegmentedControl alloc] init];

for (int i = 0; i < segments.count; i++) {
  [thControl insertSegmentWithTitle:segments[i] atIndex:i];
}

Sign up for target action:

[thControl addTarget:self action:@selector(thControlChangedSegment:) forControlEvents:UIControlEventValueChanged | UIControlEventTouchUpInside];

Profit:

- (void)thControlChangedSegment:(THSegmentedControl *)thSegmentedControl
{
    NSOrderedSet *orderedIndexes = thSegmentedControl.selectedIndexes;
    for (NSInteger selection in orderedIndexes) {
      NSLog("I'm a selected segment %@", [thSegmentedControl titleForSegmentAtIndex:index]);
    }
}

To-Do

  • Accept images for segments
  • Add tests
  • Anything else you would like to see, send through a PR

License

Released under the MIT License.

Latest podspec

{
    "name": "THSegmentedControl",
    "version": "0.1.8",
    "summary": "Multiple Selection for UISegmentedControl",
    "description": "  THSegmentedControl allows you to take in multiple selection and mirrors its next-of-kin, UISegmentedControl.n",
    "homepage": "https://github.com/tayhalla/THSegmentedControl",
    "screenshots": "https://raw.githubusercontent.com/tayhalla/THSegmentedControl/master/ReadmeAssets/THSegmentedControlStill.jpg",
    "license": "MIT",
    "authors": {
        "Taylor Halliday": "[email protected]"
    },
    "source": {
        "git": "https://github.com/tayhalla/THSegmentedControl.git",
        "tag": "0.1.8"
    },
    "source_files": "THSegmentedControl/*",
    "platforms": {
        "ios": "5.0"
    },
    "requires_arc": true
}

Pin It on Pinterest

Share This