Код: Выделить всё
WebImage(url: URL(string: url)) { image in
image.resizable()
} placeholder: {
ProgressView()
}
.aspectRatio(contentMode: .fit)
< /code>
Это моя функция снимка: < /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)
}
}
Снимок отлично работает для других компонентов Swiftui. /> Вопросы: < /strong> < /p>
Почему загруженное изображение не включается в снижение? Webimage? Я добавил репо с воспроизводимым кодом https://github.com/nauvtechnologies/sdwebimagesnapshot
.>
Подробнее здесь: https://stackoverflow.com/questions/793 ... webimage-s
Мобильная версия