【发布时间】:2016-05-31 10:24:39
【问题描述】:
我可以为滑块添加标签,但标签仅在您移动滑块时出现我需要 lebel 始终处于正确位置并且滑块的值
- (IBAction)SinP:(id)sender {
float increment = 1.0;
if ([SinP isEqual:self.SinP]){
float newValue1 = SinP.value /increment;
SinP.value = floor(newValue1) * increment;
}
UIImageView *handleView1 = [SinP.subviews lastObject];
UILabel *label = (UILabel*)[handleView1 viewWithTag:1010];
if (label==nil) {
label = [[UILabel alloc] initWithFrame:handleView1.bounds];
label.tag = 1010;
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor whiteColor];
label.textAlignment = NSTextAlignmentCenter;
[handleView1 addSubview:label];
}
label.text = [NSString stringWithFormat:@"%0.0f", self.SinP.value];
_L01.text = [NSString stringWithFormat:@"%0.0f", self.SinP.value];
self.T01.text = [@((int)SinP.value) stringValue];
}
【问题讨论】: