[翻译] TWRPickerSlider
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上,它会自动的将它自己添加到底端
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了解更多。
TWRPickerSlider requires iOS 7.x or greater.
TWRPickerSlider需要iOS7.x以上版本
从零写一个Recoil(翻译) Rewriting Recoil from scratchrecoil是facebook编写的一个库,它之所以诞生是因为人体工程学、context的性能问题和useState。这是一个非常聪明的库,几乎每个人都会找到它的用途——如果你想了解更多,请查看这段解释视频。刚开始我被图论和recoil惊到了,但渐渐的理解后,感觉也没那么特别了。也许我也可以实现一个类似的东西。我自己实现的版本和recoil
相关文章
- Academic social networks: Modeling, analysis, mining and applications 2019翻译
- 【翻译】测试替身
- 谷歌翻译停服?别慌,手把手教你一招修复 Chrome 浏览器无法翻译网页问题
- 【JS 逆向百例】某度指数 Cipher-Text、某度翻译 Acs-Token 逆向分析
- Android 本地化翻译插件,一键将你的 strings.xml 翻译为最多 104 种语言,告别手动复制黏贴
- WordPress多语言WPMLv4.6.3插件 自动翻译多国语言
- 热烈祝贺!LCTT 第一位达成翻译 500 篇成就的译者 geekpi !
- 《Hyperledger Fabric官方文档》之关键概念翻译邀请
- 《以太坊官方文档》翻译邀请
- Redis翻译开启中文版之旅(redis翻译中文版)
- ExaGear 二进制动态翻译
- 揭秘:搜狗语音实时翻译是怎么炼成的