swift - Swift ui macos ProgressView 使用未解析的标识符'ProgressView'
解决方案
此 ProgressView 仅适用于 MacOs 11,您可以在此链接中看到https://developer.apple.com/documentation/swiftui/progressview
您可以使用NSProgressIndicator
并将其包装成NSViewRepresentable
这样:
import Swift
import SwiftUI
public struct ActivityIndicator {
public enum Style {
case medium
case large
}
private var isAnimated: Bool = true
private var style: Style? = Style.medium
public init() {
}
}
#if os(macOS)
import Cocoa
import AppKit
extension ActivityIndicator: NSViewRepresentable {
public typealias Context = NSViewRepresentableContext<Self>
public typealias NSViewType = NSProgressIndicator
public func makeNSView(context: Context) -> NSViewType {
let nsView = NSProgressIndicator()
nsView.isIndeterminate = true
nsView.style = .spinning
nsView.sizeToFit()
nsView.layer?.transform = CATransform3DMakeScale(1.0, 0.6, 0.0);
nsView.controlSize = .small
return nsView
}
public func updateNSView(_ nsView: NSViewType, context: Context) {
isAnimated ? nsView.startAnimation(self) : nsView.stopAnimation(self)
}
}
#endif
推荐阅读
- autodesk-forge - Autodesk Forge:如何在 BIM 360 Docs 中查找模型的 svf 文件的 URL
- java - 如何从 SpringBoot 应用程序连接到 Azure keyvault 以使用 MSI 进行本地开发
- python - 如何修复:“在 sql 'SELECT * FROM Country' 上执行失败:没有这样的表:国家”
- java - 使用 Spring MVC 和 Kotlin,为什么忽略这个 Body?
- c++ - 可以比较两个指向成员函数的指针是否相等吗?
- responsive - 如何防止电子邮件客户端像 putsmail 那样删除媒体查询?
- share - 在核心 php 中如何在社交媒体上分享产品标题、图片和描述?
- python-3.x - 上传文件到 tmp 目录 lambda
- javascript - 使用回调参数在 Javascript 中创建函数
- python - 如何按键排序这个字典?