A drop-in replacement for UISegmentedControl for showing counts, to be used typically on a user profile.
- Customizable control with tint color, font, sizes and animation duration.
- Animated and width auto-adjusting selection indicator.
- UIBarPositioning support.
- UIAppearance support.
- ARC & 64bits.
Available in Cocoa Pods
pod 'DZNSegmentedControl'
For complete documentation, visit CocoaPods' auto-generated doc
Import "DZNSegmentedControl.h"
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];
Take a look into the sample project. Everything is there.
(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.