xcode 以编程方式更改 NSSlider 值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9867343/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 23:47:01  来源:igfitidea点击:

change NSSlider Value programmatically

objective-cxcodemacoscocoansslider

提问by Grant Wilkinson

Is there a way to make an IBOutlet of an NSSlider and then be able to change its value programmatically? slider.value =...does not work.

有没有办法制作 NSSlider 的 IBOutlet 然后能够以编程方式更改其值?slider.value =...不起作用。

Thanks!

谢谢!

回答by Schulze Thomas

You can use the methods of NSControl.

您可以使用 NSControl 的方法。

Example: [self.slider setDoubleValue:0.1];

例子: [self.slider setDoubleValue:0.1];

回答by Leo Dabus

Swift answer to this question is to use the doubleValue property to access the slider value in OSX:

这个问题的 Swift 答案是使用 doubleValue 属性来访问 OSX 中的滑块值:

slider.doubleValue = 0.1 

print(slider.doubleValue)