标签:
- (void)viewDidLoad {
[super viewDidLoad];
//步进器 固定的size (94*27), 事件驱动型控件
UIStepper *st = [[UIStepper alloc] initWithFrame:CGRectMake(10,10,300,30)];
//设置最大值
st.maximumValue = 300;
//设置最小值
st.minimumValue = 10;
//设置步长 (默认值为1 必须>0)(+一次增加的值/-一次减少的值)
st.stepValue = 10;
st.continuous = NO;
[st addTarget:self action:@selector(stepperValueChanged:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:st];
//进度条,普通视图控件,高度固定9
UIProgressView *progress = [[UIProgressView alloc] initWithFrame:CGRectMake(10,100,300,30)];
//进度条的进度属性(默认为0,0.0-1.0),值大于1,进度条一直处于满格状态
progress.progress = 0.1;
progress.tag = 101;
[self.view addSubview:progress];
}
- (void)stepperValueChanged:(UIStepper *)st{
//点击+/-号value值发生变化
UIProgressView *progress = (UIProgressView *)[self.view viewWithTag:101];
progress.progress = st.value/300;
NSLog(@"stepperValue:%f",st.value);
}
UIStepper步进器 ——事件驱动型控件,(一个+和-按钮的)
标签:
原文地址:http://www.cnblogs.com/linxiu-0925/p/5424888.html