我只需要获取 UIImage 而不是使用Kingfisher 库加载普通的 UIImageView
为了实现它,我使用 UIImageView 实现了一个解决方法:
let imageView = UIImageView()
imageView.kf_setImageWithURL(NSURL(string: cpa.imageName)!, placeholderImage: nil,
optionsInfo: [.Transition(ImageTransition.Fade(1))],
progressBlock: { receivedSize, totalSize in
print("\(receivedSize)/\(totalSize)")
},
completionHandler: { image, error, cacheType, imageURL in
anView!.image = image //anView IS NOT an UIImageView
anView!.frame.size = CGSize(width: 15.0, height: 15.0)
print("Finished")
})
这段代码完美地工作,但我想以一种更干净的方式来做。这个库中是否有仅获取 UIImage 的方法?异步和缓存