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?
The best way is to fake your own using UIScrollView
with pagination enabled. It's actually fairly easy, overlaying a scroll view with your own views for custom graphics.
An open-source horizontal picker component for iOS has just been released on GitHub.
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];
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.
来源:https://stackoverflow.com/questions/4594685/how-could-i-make-a-horizontal-picker