AsyncImage(url: URL(string: imageURL)) { image in image } placeholder: { Image(systemName: "photo.circle.fill") } .padding(40)
我试图在图像中使用图像,但它不起作用。还有,填充物也不起作用。
ar5n3qh51#
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) }
sgtfey8w2#
你看起来像这样吗
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} } }
2条答案
按热度按时间ar5n3qh51#
sgtfey8w2#
你看起来像这样吗