bap*_*482 3 macos swift swiftui
我了解到可以像这样渲染系统图像:
Image(nsImage: NSImage(imageLiteralResourceName: NSImage.addTemplateName))
Run Code Online (Sandbox Code Playgroud)
我必须使用自定义 svg 吗?
这只是一个简单的看法。
ProgressView()
Run Code Online (Sandbox Code Playgroud)
目前,它是默认的,CircularProgressViewStyle但您可以通过添加以下修饰符来手动设置它的样式:
.progressViewStyle(CircularProgressViewStyle())
Run Code Online (Sandbox Code Playgroud)
此外,样式可以是任何符合 ProgressViewStyle
您可以NSProgressIndicator直接在 SwiftUI 中使用:
struct ProgressIndicator: NSViewRepresentable {
typealias TheNSView = NSProgressIndicator
var configuration = { (view: TheNSView) in }
func makeNSView(context: NSViewRepresentableContext<ProgressIndicator>) -> NSProgressIndicator {
TheNSView()
}
func updateNSView(_ nsView: NSProgressIndicator, context: NSViewRepresentableContext<ProgressIndicator>) {
configuration(nsView)
}
}
Run Code Online (Sandbox Code Playgroud)
var body: some View {
ProgressIndicator {
$0.controlTint = .blueControlTint
}
}
Run Code Online (Sandbox Code Playgroud)
您可以替换TheNSView为NSView您需要在 SwiftUI 中使用的任何其他内容。
| 归档时间: |
|
| 查看次数: |
2638 次 |
| 最近记录: |