4

I need to rotate NSProgressIndicator by 90 deg. enter image description here

When I use the following code:

[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];

I get inappropriate result: enter image description here

This code works fine on OS X Yosemite, but not works on OS X El Capitan.

How I can fix it?

4

1 回答 1

1

如果您的进度指示器包含在视图中,那么如果您可以允许该视图的需求层,您的代码将起作用。

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 上对我有用。

于 2015-10-28T14:33:19.383 回答