本文共 1422 字,大约阅读时间需要 4 分钟。
DZNSegmentedControl
A drop-in replacement for UISegmentedControl for showing counts, to be used typically on a user profile.
一个UISegmentedControl的子类,用以扩展UISegmentedControl的功能,可以用在展示用户的信息上.
Features
Installation
Available in
你可以使用Cocoa Pods安装
pod 'DZNSegmentedControl'
How to use
For complete documentation,
你可以参考文档
Step 1
Import "DZNSegmentedControl.h" 导入头文件
Step 2
Creating a new instance of DZNSegmentedControl is very similar to what you would do with UISegmentedControl:
创建出 DZNSegmentedControl 对象,与创建 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.
你也可以参考一下示例项目.
转载地址:http://jczuo.baihongyu.com/