swiftui load image

Aug 24, 2021 swiftui

How to swift load image from url in SwiftUI

How to load a remote image from a URL in SwiftUI

As Apple introduce SwiftUI in WWDC 2020 the .SwiftUI decided to use the AsyncImage to swift load image from url when the image is downloaded from the URL or Api’s . Now just we can use AsyncImage to display image from url swift 4

for SwiftUI uiimage url

AsyncImage(url: URL(string: "https://www.leadbycode.png"))

We can use the above code to download the image from the internet.

we can use the scale the image which is downloaded using the below code

    AsyncImage(url: URL(string: "https://www.leadbycode.png"), scale: 2)

by default the scale is assume to be 1 we can change the scale by using the above code in swiftUI :

swift load image from url

display image from url swift 4

AsyncImage(url: URL(string: "https://www.leadbycode.png")) { image in


    } placeholder: {



    .frame(width: 300, height: 300)

    .clipShape(RoundedRectangle(cornerRadius: 50))

We can use the image resizable . In SwiftUI frame resizing can be done using Frame(width: framewidthsize, height: frameheightsize)