Latest 1.1.0
Homepage https://github.com/nealyoung/NYSegmentedControl
License MIT
Platforms ios 7.0, requires ARC
Authors

NYSegmentedControl is a customizable, animated replacement for UISegmentedControl inspired by controls found in Instagram, Foursquare, and other apps.

Screenshot

Features

  • Create segmented controls with animated selection indicator
  • Customize colors, gradients, fonts, etc. either directly or globally with UIAppearance
  • Configure distinct text styles for the selected segment

Animated Example

Installation

Manual

Add the files to your project manually by dragging the NYSegmentedControl directory into your Xcode project.

CocoaPods

Add pod 'NYSegmentedControl' to your Podfile, and run pod install.

Usage

Use is largely identical to UISegmentedControl. An example project is included in the NYSegmentedControlDemo directory.

// Import the class and create an NYSegmentedControl instance
#import "NYSegmentedControl.h"

// ...

NYSegmentedControl *segmentedControl = [[NYSegmentedControl alloc] initWithItems:@[@"Segment 1", @"Segment 2"]];

// Add desired targets/actions
[segmentedControl addTarget:self action:@selector(segmentSelected) forControlEvents:UIControlEventValueChanged];

// Customize and size the control
segmentedControl.borderWidth = 1.0f;
segmentedControl.borderColor = [UIColor colorWithWhite:0.15f alpha:1.0f];
segmentedControl.drawsGradientBackground = YES;
segmentedControl.segmentIndicatorInset = 2.0f;
segmentedControl.drawsSegmentIndicatorGradientBackground = YES;
segmentedControl.segmentIndicatorGradientTopColor = [UIColor colorWithRed:0.30 green:0.50 blue:0.88f alpha:1.0f];
segmentedControl.segmentIndicatorGradientBottomColor = [UIColor colorWithRed:0.20 green:0.35 blue:0.75f alpha:1.0f];
segmentedControl.segmentIndicatorAnimationDuration = 0.3f;
segmentedControl.segmentIndicatorBorderWidth = 0.0f;
[segmentedControl sizeToFit];

// Add the control to your view
self.navigationItem.titleView = self.segmentedControl;

License

This project is released under the MIT License.

Latest podspec

{
    "name": "NYSegmentedControl",
    "version": "1.1.0",
    "summary": "Animated, customizable replacement for UISegmentedControl",
    "description": "NYSegmentedControl is a customizable, animated replacement for UISegmentedControl inspired by controls found in Instagram, Foursquare, and other apps.",
    "homepage": "https://github.com/nealyoung/NYSegmentedControl",
    "screenshots": "https://github.com/nealyoung/NYSegmentedControl/raw/master/image.png",
    "license": {
        "type": "MIT",
        "file": "LICENSE.md"
    },
    "authors": {
        "Neal Young": "[email protected]"
    },
    "social_media_url": "http://nealyoung.me",
    "platforms": {
        "ios": "7.0"
    },
    "source": {
        "git": "https://github.com/nealyoung/NYSegmentedControl.git",
        "tag": "1.1.0"
    },
    "source_files": "NYSegmentedControl/*.{h,m}",
    "requires_arc": true
}

Pin It on Pinterest

Share This