0

我已经使用以下代码在 viewDidLoad 中以编程方式创建了一个 UISlider,当按下按钮时,我想隐藏该对象并可能再次使用它。我似乎无法让它工作。我尝试了许多方法,它们都可以正确构建,但都没有达到预期的效果。

CGRect frame1 = CGRectMake(-5.0, 290.0, 100.0, 10.0);
UISlider *sliderSaveurFloral = [[UISlider alloc] initWithFrame:frame1];
[sliderSaveurFloral addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventValueChanged];
[sliderSaveurFloral setBackgroundColor:[UIColor clearColor]];
sliderSaveurFloral.minimumValue = 0.0;
sliderSaveurFloral.maximumValue = 50.0;
sliderSaveurFloral.continuous = YES;
sliderSaveurFloral.value = 0.0;
[self.view addSubview:sliderSaveurFloral];
CGAffineTransform trans2 = CGAffineTransformMakeRotation(M_PI * -0.5);
sliderSaveurFloral.transform = trans2;
[sliderSaveurFloral setValue:0];
4

1 回答 1

0

UISlider 继承自 UIView。我相信您可以设置隐藏属性使其不可见。

 sliderSaveurFloral.hidden = YES; //Set it back to NO when you want it appear again

您可能还必须使其在隐藏时不交互,

 sliderSaveurFloral.userInteractionEnabled = NO; //Set it back to YES later when you need
于 2013-09-11T08:16:39.123 回答