skip to Main Content
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.

2

Answers


  1. Are you looking like this

        extension UIImageView {
        func setImage(fromUrl:String?) {
            let placeholderImage : UIImage = UIImage(systemName: "photo.circle.fill")!
            self.image = placeholderImage
            guard let url = URL(string: ~fromUrl?.replacingOccurrences(of: " ", with: "")) else {
                return
            }
            let request = ImageRequest(
                url: url,
                processors: [ImageProcessors.Resize(size: self.bounds.size)],
                priority: .veryHigh
            )
            let options = ImageLoadingOptions(placeholder: placeholderImage, transition: nil, failureImage: placeholderImage, failureImageTransition: nil)
            Nuke.loadImage(with: request, options: options, into: self, progress: nil) { _ in}
        }
    }
    
    Login or Signup to reply.
  2. 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)
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search