Skip to content

Commit

Permalink
SwiftUI 이미지 다운로드 중복 문제 및 이미지가 로드되지 않는 문제 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
J0onYEong committed Nov 22, 2024
1 parent 73721d1 commit ed82281
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ class ImageLoader: @unchecked Sendable, ObservableObject {
self.url = url
self.size = size
self.fadeOutduration = fadeOutduration

loadImage()
}

func loadImage() {

// 기존 이미지를 초기화
uiImage = nil

Task {

let image = await SimpleImageProvider.shared
Expand Down Expand Up @@ -60,10 +61,13 @@ public struct SimpleImage: View {
Image(uiImage: uiImage)
.resizable()
.aspectRatio(contentMode: .fit)

} else {

Text("")
.onAppear {

imageLoader.loadImage()
}
}
}
}

0 comments on commit ed82281

Please sign in to comment.