如何在macOS Catalina上正确添加微调器,因为Style.spinning已被弃用?



我总是用这样的NSProgressIndicator创建一个微调器

let spinner = NSProgressIndicator()
spinner.style = .spinning

它工作正常,但我最近发现 NSProgressIndicator.Style.spinning 已被弃用。我已经四处搜索,但并没有完全找到现在在macOS上创建微调器的推荐方法。任何人都可以在这里帮忙吗?

谢谢

它看起来像文档中的错误。在 macOS 10.15 中,NSProgressIndicatorBarStyleNSProgressIndicatorSpinningStyle已弃用。不知何故,NSProgressIndicatorStyleBarNSProgressIndicatorStyleSpinning,Swift 中的.bar.spinning,在文档中也被弃用,但它们不在 NSProgressIndicator.h 中。

typedef NS_ENUM(NSUInteger, NSProgressIndicatorStyle) {
NSProgressIndicatorStyleBar = 0,
NSProgressIndicatorStyleSpinning = 1
};

/* Please instead use the more modern versions of these constants.
*/
static const NSProgressIndicatorStyle NSProgressIndicatorBarStyle API_DEPRECATED_WITH_REPLACEMENT("NSProgressIndicatorStyleBar", macos(10.2,10.14)) = NSProgressIndicatorStyleBar;
static const NSProgressIndicatorStyle NSProgressIndicatorSpinningStyle API_DEPRECATED_WITH_REPLACEMENT("NSProgressIndicatorStyleSpinning", macos(10.2,10.14)) = NSProgressIndicatorStyleSpinning;

这种风格并没有被弃用;他们只是让名称保持一致,所以更容易将它们变成 Swift。

最新更新