我能够这样做(使用4.10.1版本):
extension UIImageView {
func test() {
self.kf.indicatorType = .activity
}
}现在,对于5.0.0版本,如果出现以下错误,就不可能这样做了:
无法分配属性:“自我”是不可变的
我仍然可以在分机外正常设置它。是否有一种方法可以从indictorType扩展内部设置UIImageView?
发布于 2018-12-16 11:12:42
与库的GitHub存储库上的这个问题一样,kf变量现在引用了一个用于Kingfisher性能考虑的结构,因此为了处理它,我们需要为它创建一个副本,如下所示:
extension UIImageView {
func test() {
var kf = self.kf
kf.indicatorType = .activity
}
}发布于 2018-12-13 11:59:40
extension UIImageView {
func setImages(url:String){
let activityInd = UIActivityIndicatorView()
activityInd.center = CGPoint(x: self.frame.size.width / 2,
y: self.frame.size.height / 2)
activityInd.color = UIColor.red
self.addSubview(activityInd)
activityInd.startAnimating()
self.kf.setImage(with: URL(string: url), placeholder: #imageLiteral(resourceName: "user-icn"), options: nil, progressBlock: nil) { (img, err, cache, url) in
activityInd.stopAnimating()
}
}}
https://stackoverflow.com/questions/53761169
复制相似问题