HKLSegmentedControl 1.1.0

HKLSegmentedControl 1.1.0

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Jun 2015

Maintained by Hirohito Kato.




A subclass of UISegmentedControl which supports dynamically value changing.

HKLSegmentedControl is a fully compatible class with UISegmentedControl. In addition to that, it supports touch moving events. The delegate method is called each time when you swipe on the control.

:bulb: Features

  • Fully compatible with UISegmentedControll class
  • Support dynamic event handling
  • Of course, support Value Changed event, too.
  • Works on iOS

:book: Usage

Interface

is very simple!

@interface HKLSegmentedControl : UISegmentedControl
@property (nonatomic, weak)id<HKLSegmentedControlDelegate> delegate;
@property (nonatomic, readonly)NSInteger highlightedSegmentIndex;
@end

@protocol HKLSegmentedControlDelegate <NSObject>
@optional
- (void)segmentedControl:(HKLSegmentedControl*)control didBeginTouch:(NSInteger)highlightedSegmentIndex;
- (void)segmentedControl:(HKLSegmentedControl*)control didChangedHighlightedIndex:(NSInteger)highlightedSegmentIndex;
@end

Receive update events

Use segmentedControl:didChangedHighlightedIndex: delegate method.

@interface ViewController () <HKLSegmentedControlDelegate>
@property (weak, nonatomic) IBOutlet HKLSegmentedControl *segment;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    _segment.delegate = self;
}

// Receive dynamic update events
- (void)segmentedControl:(HKLSegmentedControl *)control didChangedHighlightedIndex:(NSInteger)highlightedSegmentIndex {
    // Do anything!
}

// Can receive Value Changed(=touch up inside) event.
- (IBAction)selected:(id)sender {
}
@end

Requirements

iOS 7 or later

Installation

Author

Hirohito Kato

License

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