这个也是很简单的控件,下面是一些用法
UIStepper *steper = [[UIStepper alloc] initWithFrame:CGRectMake(50, 50, 100, 100)];
[self.view addSubview:steper];
steper.tag = 100;
// 设置最值
steper.minimumValue = 1;
steper.maximumValue = 30;
steper.stepValue = 2; // 每次递增2
steper.value = 10;// 初值为10
[steper setWraps:YES];// 是否循环
[steper addTarget:self action:@selector(change:) forControlEvents:UIControlEventValueChanged];
[steper release];
- (void)change:(UIStepper *)stepper{
// 判断stepper 是否连续,用continuous
if (stepper.continuous) {
// steper.value 是取出当前值
NSLog(@"%f", stepper.value);
}else{
NSLog(@"jian");
}
}
时间: 2024-10-14 23:05:06