iosswiftiphoneswiftuixcode14

Learning swift and Xcode. Facing a issue in the syntax


AsyncImage(url: URL(string: imageURL)) { image in
   image
} placeholder: {
   Image(systemName: "photo.circle.fill")
}
.padding(40)

I'm trying to use the image in the image but it isn't working. Also, the padding isn't working.


Solution

  • var defaultImage: Image = Image("add-user")
    
    AsyncImage(url: URL(string: imageUrl )) { image in
        image.resizable().aspectRatio(contentMode: .fill).frame(width: 120, height: 120).background(Color.red).cornerRadius(60)
    }placeholder: {
            defaultImage.resizable().aspectRatio(contentMode: .fill).cornerRadius(60).frame(width: 120, height: 120)
    }