iOS开篇——UI之UIStepper (计步器)
UIStepper * stepper = [[UIStepper alloc]initWithFrame:CGRectMake(50, 100, 150, 40)]; //********最小值和最大值 stepper.maximumValue = 100; stepper.minimumValue = 0; //设置跃迁值 *** stepper.stepValue = 0.1; //设置镂空颜色 stepper.tintColor = [UIColor redColor]; //添加点击事件 [stepper addTarget:self action:@selector(onClick:) forControlEvents:UIControlEventValueChanged];
实现点击事件
- (void)onClick:(UIStepper *)stepper{ NSLog(@"%.02lf",stepper.value); UILabel * label = [self.view viewWithTag:1]; label.text = [NSString stringWithFormat:@"%0.2f",stepper.value]; }