Awesome
XDNumberPicker
XDNumberPicker is a number picker component for iOS platform.
Installation
- Clone the repository somewhere on your hard drive
- Open your project in XCode
- Drag and drop XDNumberPicker folder into your project
Usage
You can instantiate XDNumberPicker either from code or from nib/storyboard. It contains three components, a value Label and two Buttons (plus and minus). The order can be either horizontal or vertical.
1.Code
This will create a picker with default values and no delegate.
XDNumberPicker* numberPicker= [[XDNumberPicker alloc] initWithFrame:CGRectMake(190, 20, 110, 35)];
[myView addSubview:numberPicker];
If you want more control you can use:
XDNumberPicker* numberPicker= [[XDNumberPicker alloc] initWithFrame:rect initialValue:1 minValue:0 maxValue:20 step:1 isVertical:NO delegate:self]
2.Storyboard/nib
Simply create a UIView, set it's frame and set Custom Class to XDNumberPicker. If you wish to set the delegate, change any of the images or min/max values and step, simply connect the picker as an IBOutlet and handle it in code.
When instantiating the picker from the nib, component orientation will depend on the frame size.
bool vertical= frame.size.height > frame.size.width;
Control order
Order of components can be customized.
[picker setControlOrder:@"MVP"];
- M - Minus
- V - Value
- P - Plus
Component order is left to right(horizontal) and top to bottom(vertical). If the string value doesn't match the regex, the order will stay the same. Default order is MVP for horizontal, PVM for vertical orientation.