Skip to content

A drop-in replacement for UISegmentedControl for showing counts, to be used typically on a user profile

License

Notifications You must be signed in to change notification settings

nebuto/DZNSegmentedControl

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DZNSegmentedControl

A drop-in replacement for UISegmentedControl for showing counts, to be used typically on a user profile.

gif

Features

  • Customizable control with tint color, font, sizes and animation duration.
  • Animated and width auto-adjusting selection indicator.
  • UIBarPositioning support.
  • UIAppearance support.
  • ARC & 64bits.

Installation

Available in Cocoa Pods

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) 2014 Ignacio Romero Zurbuchen [email protected]

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.

About

A drop-in replacement for UISegmentedControl for showing counts, to be used typically on a user profile

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 97.6%
  • Ruby 2.4%