如何将NSProgressIndicator旋转90度

4
我需要将NSProgressIndicator旋转90度。 输入图像描述 当我使用以下代码时:
[self.progressIndicator1 setWantsLayer:NO];
[self.progressIndicator1 setFrameCenterRotation:90];
[self.progressIndicator1 setMinValue:0];
[self.progressIndicator1 setMaxValue:100];
[self.progressIndicator1 setDoubleValue:50];
[self.progressIndicator1 displayIfNeeded];

[self.progressIndicator2 setWantsLayer:NO];
[self.progressIndicator2 setFrameCenterRotation:90];
[self.progressIndicator2 displayIfNeeded];

我得到了不恰当的结果: 输入图像描述 这段代码在OS X Yosemite上运行良好,但在OS X El Capitan上无法运行。
我该如何修复它?
1个回答

1
如果您的进度指示器包含在一个视图中,那么如果您允许该视图的wantsLayer,则您的代码将起作用。
self.view.wantsLayer = YES;
self.progressBar1.doubleValue = 60.0;
self.progressBar2.doubleValue = 60.0;

[self.progressBar1 setWantsLayer:NO];
[self.progressBar1 setFrameCenterRotation:90];

[self.progressBar2 setWantsLayer:NO];
[self.progressBar2 setFrameCenterRotation:90];
[self.progressBar2 displayIfNeeded];

这个在El Capitan上对我有用。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接