#pragma mark - 创建控件 UIStepper
- (void)createSteppper
{
UIStepper *stepper = [[UIStepper alloc] initWithFrame:CGRectMake(130, 150, 50, 20)];
// 设置 stepper 最小值,默认是0
stepper.minimumValue = 20;
// 设置 stepper 最大值,默认是100
stepper.maximumValue = 120;
// 设置每一次加减多少
stepper.stepValue = 10;
// 设置当前 stepper 的默认值
stepper.value = 50;
[self addSubview:stepper];
[stepper release];
// 绑定点击事件
[stepper addTarget:self action:@selector(stepperAction:) forControlEvents:UIControlEventValueChanged];
}
- (void)stepperAction:(UIStepper *)sender
{
NSLog(@"stepper");
self.view.frame = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.frame.size.width, sender.value);
// self.view.frame = CGRectMake(50, 150, self.frame.size.width, sender.value);
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文地址:http://blog.csdn.net/yadong_zhao/article/details/46777821