Snail—UI学习之数字输入控件UIStepper

来源:互联网 发布:佳能官方网站软件下载 编辑:程序博客网 时间:2024/05/29 15:43
- (void)viewDidLoad{    [super viewDidLoad];// Do any additional setup after loading the view.    self.view.backgroundColor = [UIColor redColor];    [self createStepper];    [self createLabel];}- (void)createLabel{        _label = [[UILabel alloc] initWithFrame:CGRectMake(100, 70, 50, 50)];    _label.text = @"10";    _label.backgroundColor = [UIColor greenColor];    _label.textAlignment = NSTextAlignmentCenter;        [self.view addSubview:_label];}- (void)createStepper{        //stepper 不受宽、高的影响、是固定的    UIStepper * stepper = [[UIStepper alloc] initWithFrame:CGRectMake(100, 200, 100, 100)];        //设置最小值    stepper.minimumValue = 10;    //最大值    stepper.maximumValue = MAXFLOAT;    //设置每次增加的单位大小    stepper.stepValue = 10;        //长按速度加快    stepper.continuous = YES;    //加到最大变成最小值  减到最小值变成最大值    stepper.autorepeat = YES;    stepper.wraps = YES;        //添加点击事件 UIControlEventTouchValueChanged    [stepper addTarget:self action:@selector(changed:) forControlEvents:UIControlEventValueChanged];            [self.view addSubview:stepper];}




0 0