如何使NSSlider以编程方式垂直?

时间:2015-09-01 14:44:13

标签: swift cocoa

我编写了一个Mac应用程序并以编程方式创建了一些NSSlider。默认NSSlider的方向是水平的。 如何让NSSlider垂直?

1 个答案:

答案 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)