Am downloading the images like this and binding to widget UI.
Correct me how can I proceed these memory limit issue.
struct NetworkImage: View {
let url: URL?
var viewDimension : CGFloat = 46
var body: some View {
if let url = url, let imageData = try? Data(contentsOf: url),
let uiImage = UIImage(data: imageData) {
AnyView( Image(uiImage: uiImage)
.resizable()
.aspectRatio(1, contentMode: .fit)
.frame(width: viewDimension, height: viewDimension, alignment: .center)
.border(Color(red: 0.957, green: 0.957, blue: 0.957), width: 2.0)
.cornerRadius(4)
)
}
else {
AnyView( EmptyView() )
}
}
}
Topic:
App & System Services
SubTopic:
General
Tags: