TWRPickerSlider

https://github.com/chasseurmic/TWRPickerSlider

Usage

Add the dependency to your Podfile:

用 Podfile 添加依赖关系

platform :bios
pod 'TWRPickerSlider’, ‘~> 1.0’
...

Run pod install to install the dependencies.

运行 pod install 来安装依赖

Next, import the header file wherever you want to use the picker:

下一步,导入头文件

#import "TWRSliderStackedView.h"
#import "TWRPickerSlider.h"

You should first initialize your TWRPickerSlider as such:

你需要用以下的方式来初始化对象:

TWRPickerSlider *slider1 = [[TWRPickerSlider alloc] init];

…and assign some objects for the picker:

然后,你可以给 picker 赋值几个对象:

slider1.pickerObjects = @[obj1, obj2, obj3];

Objects passed to the picker can be of any type, provided they conform to the TWRPickerSliderDatasource protocol. Said protocol only requires the user to implement the following method, which returns the string that the picker will display for the object:

对象可以是任意类型,你只需要给TWRPickerSliderDatasource提供字符串数据即可:

- (NSString *)twr_pickerTitle;

Then set the picker delegate to be your view controller and implement theTWRPickerSliderDelegate protocol:

然后设置代理到你的控制器中,并实现协议:

// Set Delegate
slider1.delegate = self; // TWRPickerSliderDelegate
- (void)objectSelected:(id<TWRPickerSliderDatasource>)selectedObject sender:(TWRPickerSlider *)sender{
NSLog(@"Selected object: %@", [selectedObject twr_pickerTitle]);
}

Finally add you TWRPickerSlider instance to your view. It will automatically position itself at the bottom of the view and animate / slide when pressed.

最后添加 TWRPickerSlider 到你的view上,它会自动的将它自己添加到底端

Stacking pickers

Alternatively, if you have or want to display more than one picker at a time, you can instantiate a TWRSliderStackedView object and assign it an array of TWRPickerSlider.

另外,如果你想在同一时间显示超过一个的picker,你可以初始化TWRSliderStackedView对象,然后在它的数组对象中赋值TWRPickerSlider对象。

TWRSliderStackedView *stack = [[TWRSliderStackedView alloc] init];
stack.sliders = @[slider1, slider2, slider3];
[self.view addSubview:stack];

Again, the stacked view will position itself at the bottom of the current view. If you’re working inside a tab bar controller, or if you don’t want the stacked view to stick at the bottom of the view controller, you can use one of the following two methods:

这个 stacked view将会把它自己安置在当前view的底部,如果你是在Tab bar控制器中作业,或者说你不想让stacked view在这个控制器的底端,你可以用下面的方法来设置:

- (instancetype)initWithBottomPadding:(NSUInteger)padding;
- (instancetype)initWithTabBar;

See the demo project for more details.

你可以看demo了解更多。

Requirements

TWRPickerSlider requires iOS 7.x or greater.

TWRPickerSlider需要iOS7.x以上版本

[翻译] TWRPickerSlider的更多相关文章

  1. 《Django By Example》第五章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者@ucag注:大家好,我是新来的翻译, ...

  2. 《Django By Example》第四章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:祝大家新年快乐,这次带来<D ...

  3. [翻译]开发文档:android Bitmap的高效使用

    内容概述 本文内容来自开发文档"Traning > Displaying Bitmaps Efficiently",包括大尺寸Bitmap的高效加载,图片的异步加载和数据缓存 ...

  4. 【探索】机器指令翻译成 JavaScript

    前言 前些时候研究脚本混淆时,打算先学一些「程序流程」相关的概念.为了不因太枯燥而放弃,决定想一个有趣的案例,可以边探索边学. 于是想了一个话题:尝试将机器指令 1:1 翻译 成 JavaScript ...

  5. 《Django By Example》第三章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:第三章滚烫出炉,大家请不要吐槽文中 ...

  6. 《Django By Example》第二章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:翻译完第一章后,发现翻译第二章的速 ...

  7. 《Django By Example》第一章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:本人目前在杭州某家互联网公司工作, ...

  8. 【翻译】Awesome R资源大全中文版来了,全球最火的R工具包一网打尽,超过300+工具,还在等什么?

    0.前言 虽然很早就知道R被微软收购,也很早知道R在统计分析处理方面很强大,开始一直没有行动过...直到 直到12月初在微软技术大会,看到我软的工程师演示R的使用,我就震惊了,然后最近在网上到处了解和 ...

  9. ASP.NET MVC with Entity Framework and CSS一书翻译系列文章之第一章:创建基本的MVC Web站点

    在这一章中,我们将学习如何使用基架快速搭建和运行一个简单的Microsoft ASP.NET MVC Web站点.在我们马上投入学习和编码之前,我们首先了解一些有关ASP.NET MVC和Entity ...

随机推荐

  1. ES6 rest参数和扩展运算符

    rest参数 ES6引入了rest参数(形式为“…变量名”).其中rest参数搭配的变量是一个数组可以使用数组的一切操作. 例: function rest(...values){ let sum=0 ...

  2. JavaScript数据结构-9.循环链表

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  3. typeof, offsetof 和container_of

    要理解Linux中实现的双向循环链表("侵入式"链表),首先得弄明白宏container_of. 本文尝试从gcc的关键字typeof和宏offsetof入手,循序渐进地剖析宏co ...

  4. centOS 7下无法启动网络(service network start)错误解决办法(应该是最全的了。。。)

    今天在centOS 7下更改完静态ip后发现network服务重启不了,翻遍了网络,尝试了各种方法,终于解决了. 现把各种解决方法归纳整理,希望能让后面的同学少走点歪路... 首先看问题:执行serv ...

  5. [PY3]——内置数据结构(5)——字符串编码

    py2和py3中关于字符串的最大区别? python2中只有 unicode类型 而python3中有 string bytes两种类型 关于string和bytes的区分? 1.str是文本序列.b ...

  6. 如何创建一个基于Node的HTTP服务器

    首先创建一个HTTP服务器. var http = require('http'); function serve(request,response) { console.log(request.me ...

  7. golang学习之接口型函数

    先说下使用接口型函数的好处: 1.不必将某个接口函数附在某个type上面,保证了命名随意 2. 可以直接调用函数或者使用该接口,两两不耽误 直接上代码吧: // interface_func proj ...

  8. Vue2.0学习笔记:Vue事件修饰符的使用

    事件处理 如果需要在内联语句处理器中访问原生DOM事件.可以使用特殊变量$event,把它传入到methods中的方法中. 在Vue中,事件修饰符处理了许多DOM事件的细节,让我们不再需要花大量的时间 ...

  9. [javaSE] IO流(FIle对象递归文件列表)

    获取File对象,new出来,构造参数:String目录名 调用File对象的list()方法,获取String[]数组文件名称 循环数组,列出所有文件包含隐藏文件 递归列出所有的数据 定义一个静态方 ...

  10. 高并发系列之——MQ消息中间件Kafka

    1.前言 1.1 包路径和源码 下载链接 基于发布订阅的分布式消息系统,使用scala语言编写. 特点:采用分区机制,每个分区可以放到不同的服务器上,提高了吞吐率,同时基于磁盘存储,以及副本机制可以确 ...