Skip to content
A drop-in replacement for UISegmentedControl for showing counts, to be used typically on a user profile
Objective-C Ruby
Branch: master
Clone or download
Ignacio Romero
Latest commit 3ba556f Nov 14, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
DZNSegmentedControl.xcodeproj Lowering the deployment target to 9.0 Nov 14, 2017
DZNSegmentedControl
DZNSegmentedControlExamples Adding Carthage support + project restructuring Nov 13, 2017
DZNSegmentedControlTests Adding Carthage support + project restructuring Nov 13, 2017
Screenshots Updates README Feb 4, 2016
.gitignore first commit Mar 11, 2014
DZNSegmentedControl.podspec Version bump (1.4) Nov 13, 2017
LICENSE Update LICENSE Aug 7, 2015
README.md Updating readme Nov 13, 2017

README.md

DZNSegmentedControl

License Pod Version Carthage compatible BuddyBuild

A drop-in replacement for UISegmentedControl for showing counts, images and many other useful features.

Demo Gif

Features

  • Fully customizable control with tint color, font, sizes and animation duration.
  • Animated and width auto-adjusting selection indicator.
  • UIBarPositioning support.
  • UIAppearance support.
  • UIScrollView extension for scroll offset binding.

Installation

Available in CocoaPods

pod 'DZNSegmentedControl'

How to use

For complete documentation, visit CocoaPods' auto-generated doc

Step 1

Import "DZNSegmentedControl.h"

Step 2

Creating a new instance of DZNSegmentedControl is very similar to what you would do with UISegmentedControl:

NSArray *items = @[@"Tweets", @"Following", @"Followers"];
    
DZNSegmentedControl *control = [[DZNSegmentedControl alloc] initWithItems:items];
control.tintColor = [UIColor blueColor];
control.delegate = self;
control.selectedSegmentIndex = 1;
    
[control addTarget:self action:@selector(selectedSegment:) forControlEvents:UIControlEventValueChanged];

You can additionally set more properties:

[control setCount:@(12) forSegmentAtIndex:0];
[control setTitle:@"Hello" forSegmentAtIndex:1];
[control setEnabled:NO forSegmentAtIndex:2];

Sample project

Take a look into the sample project. Everything is there.

License

(The MIT License)

Copyright (c) 2015 Ignacio Romero Zurbuchen iromero@dzen.cl

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

You can’t perform that action at this time.