CocoaPods trunk is moving to be read-only. Read more on the blog, there are 14 months to go.
| TestsTested | ✗ |
| LangLanguage | Obj-CObjective C |
| License | MIT |
| ReleasedLast Release | Dec 2014 |
Maintained by Rob Phillips.
A simple vertical stepper control for iOS that is similar in function to the UIStepper control. Personally, I think it was short-sighted of Apple to only release a horizontal stepper control, so this was created to remedy that.
Note: RPVerticalStepper is a subclass of UIControl so it inherits all characteristics of a typical control object.
stringWithFormat method) to show it as whole number.value (CGFloat, defaults to 1) : The current value of the stepper controlminimumValue (CGFloat, defaults to 1) : The minimum value the stepper value can be before the decrement button is disabledmaximumValue (CGFloat, defaults to 99) : The maximum value the stepper value can be before the increment button is disabledstepValue (CGFloat, defaults to 1) : The amount that the value is changed by when the increment or decrement buttons are pressedautoRepeat (BOOL, defaults to YES) : Sets whether the stepper should keep changing the value for as long as the user's finger is pressed down on the controlautoRepeatInterval (CGFloat, defaults to 0.5 seconds) : Sets the interval at which auto-repeat should change the stepper valueIBAction to the Value Changed event in Interface BuilderRPVerticalStepperDelegate protocol and then use the stepperValueDidChange: method to know when the stepper value has changed The code base comes with an example project:
And here is a basic example assuming you've added the control to a NIB or Storyboard file:
In the .h header file:
#import <UIKit/UIKit.h>
#import "RPVerticalStepper.h"
@interface ViewController : UIViewController
@property (nonatomic, weak) IBOutlet UILabel *stepperLabel;
@property (nonatomic, weak) IBOutlet RPVerticalStepper *stepper;
@endIn the .m implementation file:
#import "ViewController.h"
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Set some different defaults
self.stepper.value = 1.0f;
self.stepper.minimumValue = -100.0f;
self.stepper.maximumValue = 100.0f;
self.stepper.stepValue = 5.0f;
self.stepper.autoRepeatInterval = 0.1f;
}
// This is called from the control event hooked up to the control in the Storyboard
- (IBAction)stepperDidChange:(RPVerticalStepper *)stepper
{
self.stepperLabel.text = [NSString stringWithFormat:@"%.f", stepper.value];
}
@endEssentially, this code is free to use in commercial and non-commercial projects with no attribution necessary.
See the LICENSE file for more details.