Code: Select all
WebImage(url: URL(string: url)) { image in
image.resizable()
} placeholder: {
ProgressView()
}
.aspectRatio(contentMode: .fit)
< /code>
Dies ist meine Snapshot-Funktion: < /p>
func snapshot(of view: T) -> UIImage {
let controller = UIHostingController(rootView: view)
let hostingView = controller.view
let targetSize = hostingView?.intrinsicContentSize ?? .zero
hostingView?.bounds = CGRect(origin: .zero, size: targetSize)
hostingView?.backgroundColor = .clear
let renderer = UIGraphicsImageRenderer(size: targetSize)
return renderer.image { _ in
hostingView?.drawHierarchy(in: hostingView!.bounds, afterScreenUpdates: true)
}
}
Der Snapshot funktioniert perfekt für andere Swiftui -Komponenten. /> Fragen: < /strong> < /p>
Warum wird das heruntergeladene Bild nicht in den Snapshot aufgenommen? WebImage? < /Li>
< /ol>
Jede Hilfe wäre sehr geschätzt! Ich habe ein Repo mit reproduzierbarem Code hinzugefügt>