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
change NSSlider Value programmatically
提问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)