问题描述
我想为我的应用程序制作一个水平选择器,但我一直都很新。
I want to make a horizontal picker for my app, but I'm kinda new at all this. Could someone provide an easy to follow guide on how I'd make this?
推荐答案
iOS开源水平选择器组件刚刚在上发布。
An open-source horizontal picker component for iOS has just been released on GitHub.
它可以添加到UITableViewCell如下(在 tableView:cellForRowAtIndexPath:
):
It can be added to a UITableViewCell as follows (in tableView:cellForRowAtIndexPath:
):
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
STHorizontalPicker *horizontalPickerView = [[STHorizontalPicker alloc] initWithFrame:cell.frame];
horizontalPickerView.name = @"myPicker";
[horizontalPickerView setMinimumValue:0.0];
[horizontalPickerView setMaximumValue:100.0];
[horizontalPickerView setSteps:100];
[horizontalPickerView setDelegate:self];
[horizontalPickerView setValue:50.0];
它没有以任何方式拥有UIPickerView的所有功能,方法来实现一个控件(UIScrollView包含一个UIView与多个CATextLayers的标记),并有一些很好的功能,如捕捉到标记。
It doesn't have all of the features of a UIPickerView by any means, but it illustrates one possible way to implement a control (a UIScrollView containing a UIView with multiple CATextLayers for the markers) and has a couple of nice features like snapping to markers.
这篇关于我怎么能做一个水平选择器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!