码迷,mamicode.com
首页 > 其他好文 > 详细

[翻译] DZNSegmentedControl

时间:2015-05-27 22:46:49      阅读:262      评论:0      收藏:0      [点我收藏+]

标签:

DZNSegmentedControl

技术分享

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

一个UISegmentedControl的子类,用以扩展UISegmentedControl的功能,可以用在展示用户的信息上.

技术分享

 

Features

  • Customizable control with tint color, font, sizes and animation duration. 可以定制填充颜色,字体,尺寸以及动画的方向
  • Animated and width auto-adjusting selection indicator. 可以做动画以及自动适应.
  • UIBarPositioning support. 支持UIBarPositioning
  • UIAppearance support. 支持UIAppearance
  • ARC & 64bits. ARC 以及 64位

 

Installation

Available in Cocoa Pods

你可以使用Cocoa Pods安装

pod ‘DZNSegmentedControl‘

 

How to use

For complete documentation, visit CocoaPods‘ auto-generated doc

你可以参考文档 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:

创建出 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.

你也可以参考一下示例项目.

 

 

[翻译] DZNSegmentedControl

标签:

原文地址:http://www.cnblogs.com/YouXianMing/p/4532795.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!