Avoid using UIImage(contentsOfFile:), as it can lead to excessive memory consumption, especially with large images. Instead, AsyncImage works perfectly, even with local files. Here’s an example:
AsyncImage(url: url) { image in
image
.resizable(resizingMode: .stretch)
.scaledToFit()
} placeholder: {
Rectangle()
}
AsyncImage efficiently handles image loading and display, reducing the risk of memory issues.
Topic:
App & System Services
SubTopic:
General
Tags: