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.
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
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
iOS 7 or later
Hirohito Kato
HKLSegmentedControl is available under the MIT license. See the LICENSE file for more info.