1

我正在使用 AlamofireImage,我注意到它具有设置所需图像的内容类型的功能。但是,我看不到设置占位符图像本身的内容类型的可能性。

例如,现在在我cellForRow正在做的方法中:

let filter = AspectScaledToFillSizeFilter(size: cell.myPhoto.frame.size) 
 cell.myPhoto.af_setImage(
     withURL: URL(string: data.photo)!,
     placeholderImage: UIImage(named: "placeholderImg"),
     filter: filter,
     imageTransition: .crossDissolve(0.2)
 )

有没有办法设置例如内容模式=center仅在占位符图像上,同时保持AspectScaledToFillSizeFilter原始图像的内容模式?

4

2 回答 2

2

contentMode在获取图像之前将图像视图的设置为怎么样.center,并在完成块中重置contentMode为( a.scaleToFill的默认值)?contentModeUIImageView

cell.myPhoto.contentMode = .center
cell.myPhoto.af_setImage(withURL: imageURL, placeholderImage: #imageLiteral(resourceName: "placeholderImg"), filter: filter, completion: { (response) in
    cell.myPhoto.contentMode = .scaleToFill
})
于 2017-02-01T21:34:43.363 回答
0

在Swift 3-Alamofire 3中使用占位符图像下载图像

  cell.myPhoto.af_setImage(withURL: url!, placeholderImage: UIImage(named: "handi.jpg"), filter: nil, progress: nil, progressQueue: DispatchQueue.main, imageTransition: .noTransition, runImageTransitionIfCached: false) { (response) in

}
于 2017-07-19T09:15:19.640 回答