【问题标题】:How to rotate NSProgressIndicator by 90 deg如何将 NSProgressIndicator 旋转 90 度
【发布时间】:2015-10-09 10:22:50
【问题描述】:

我需要将 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 上不运行。

我该如何解决?

【问题讨论】:

    标签: cocoa osx-elcapitan nsprogressindicator


    【解决方案1】:

    如果您的进度指示器包含在视图中,那么如果您可以允许该视图的 WantLayer,您的代码就可以工作。

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

    【讨论】:

      猜你喜欢
      • 2010-11-21
      • 2012-12-23
      • 2014-04-27
      • 1970-01-01
      • 1970-01-01
      • 2011-03-22
      • 2013-02-13
      • 1970-01-01
      相关资源
      最近更新 更多