我编写了一个Mac应用程序并以编程方式创建了一些NSSlider。默认NSSlider的方向是水平的。 如何让NSSlider垂直?
答案 0 :(得分:1)
目标C
我是用这个来做的:
self.yourSlider.frameRotation = 90.0;
CGRect frame = self.yourSlider.frame;
float tmp = frame.size.height;
frame.size.height = frame.size.width;
frame.size.width = tmp;
[self.yourSlider setFrame:frame];
[self.yourSlider setWantsLayer:TRUE];
<强>夫特强>
我想Swift版本将是:
self.yourSlider.frameRotation = 90.0
var frame: CGRect = self.yourSlider.frame
var tmp: Float = frame.size.height
frame.size.height = frame.size.width
frame.size.width = tmp
self.yourSlider.frame = frame
self.yourSlider.setWantsLayer(TRUE)