1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| #import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad { [super viewDidLoad];
UIStepper *stepper = [[UIStepper alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
stepper.minimumValue = 0;
stepper.maximumValue = 10;
stepper.value = 4;
stepper.stepValue = 2;
[stepper setTintColor:[UIColor orangeColor]];
[stepper addTarget:self action:@selector(valueChange:) forControlEvents:UIControlEventValueChanged];
stepper.continuous = YES;
stepper.autorepeat = YES;
stepper.wraps = YES; [self.view addSubview:stepper]; } -(void)valueChange:(UIStepper*)stepper{ NSLog(@"%lf",stepper.value); } @end
|