Skip to content

Latest commit

 

History

History
46 lines (30 loc) · 1.51 KB

README.md

File metadata and controls

46 lines (30 loc) · 1.51 KB

NXTSegmentedControl

Pod Version Travis Status

The styled swipeable segmented control used in Next

NXTSegmentedControl

Installation

Either manually add the NXTSegmentedControl.h/m files to your project, or add the NXTSegmentedControl cocoapod by adding the following line to your podfile:

pod 'NXTSegmentedControl'

Usage

Start by importing the header.

#import <NXTSegmentedControl/NXTSegmentedControl.h>

Create the segmented control, and customize the appearance.

NXTSegmentedControl *segmentedControl = [[NXTSegmentedControl alloc] initWithItems:@[@"Post", @"Comments"]];
segmentedControl.tintColor = [UIColor redColor];
[segmentedControl addTarget:self action:@selector(segmentedControlValueChanged:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview: segmentedControl];

Finally implement your action method.

- (void)segmentedControlValueChanged:(id)sender {
    NXTSegmentedControl *segmentedControl = (NXTSegmentedControl *)sender;
    NSString *t = [NSString stringWithFormat:@"%d", segmentedControl.selectedSegmentIndex];
    NSLog(t);
}

NXTSegmentedControl uses the target action pattern just like most controls from UIKit. This creation code should be nearly identical to UISegmentedControl creation.