【发布时间】:2016-11-08 12:27:52
【问题描述】:
我在 Apple 文档中找到了下面的代码并将其添加到我的 viewDidLoad 方法中,但是当我运行代码时滑块没有出现。
CGRect frame = CGRectMake(0.0, 0.0, 200.0, 10.0);
UISlider *slider = [[UISlider alloc] initWithFrame:frame];
[slider addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventValueChanged];
[slider setBackgroundColor:[UIColor clearColor]];
slider.minimumValue = 0.0;
slider.maximumValue = 50.0;
slider.continuous = YES;
slider.value = 25.0;
【问题讨论】:
-
这些数字应该都是浮点数。
-
你的问题很有用:)
-
这里是这个问题的 [swift 版本] (stackoverflow.com/questions/30530286/…)。