iOS-视图-UIStepper 步进器 加减条

宽高不能改变

//定义label 显示 加减条 值
    label = [[UILabel alloc] initWithFrame:CGRectMake(100, 10, 100, 40)];
    label.font = [UIFont boldSystemFontOfSize:30.0];
    [self.view addSubview:label];
    //[label release];


    //加减条
    UIStepper* stepper = [[UIStepper alloc] initWithFrame:CGRectMake(50, 50, 200, 50)];
    //最小值
    [stepper setMinimumValue:0.0];
    //最大值
    [stepper setMaximumValue:10.0];
    //步进
    [stepper setStepValue:1.0];
    //value 是否 循环
    [stepper setWraps:YES];
    //自动加减
    //[stepper setAutorepeat:YES];//按住后时候连续增长还是增长一个单位
    //[stepper setContinuous:NO];//按住时是否一直变化,还是松开后再变化,变化多少取决于按住的时长
    //事件
    [stepper addTarget:self action:@selector(stepper:) forControlEvents:UIControlEventValueChanged];
    [self.view addSubview:stepper];
    [stepper release];
    
    
    label.text = [NSString stringWithFormat:@"%.0lf",stepper.value];
    
/*
//设置控制器背景图片
- (void)setBackgroundImage:(UIImage*)image forState:(UIControlState)state;

//获取背景图片
- (UIImage*)backgroundImageForState:(UIControlState)state;

//通过左右按钮的状态设置分割线的图片
- (void)setDividerImage:(UIImage*)image forLeftSegmentState:(UIControlState)leftState rightSegmentState:(UIControlState)rightState;
//获取分割线图片
- (UIImage*)dividerImageForLeftSegmentState:(UIControlState)state rightSegmentState:(UIControlState)state;

//设置和获取加号按钮的图片
- (void)setIncrementImage:(UIImage *)image forState:(UIControlState)state;
- (UIImage *)incrementImageForState:(UIControlState)state;

//设置和获取减号按钮的图片
- (void)setDecrementImage:(UIImage *)image forState:(UIControlState)state;
- (UIImage *)decrementImageForState:(UIControlState)state;
*/
    
///事件 控制值
- (void)stepper:(UIStepper*)stepper{
    label.text = [NSString stringWithFormat:@"%.0lf",stepper.value];
}

你可能感兴趣的:(iOS-视图-UIStepper 步进器 加减条)