圖片下載之前,我想開始活動指標。如何運行活動指標直到下載圖片?
這裏是我的圖片下載功能,使用URL
extension UIImageView {
func downloadImage(from url : String){
let urlRequest = URLRequest(url: URL(string: url)!)
let task = URLSession.shared.dataTask(with: urlRequest){(data,response,error)in
if error != nil {
print("error...")
}
DispatchQueue.main.async {
self.image = UIImage(data:data!)
}
}
task.resume()
}
我的問題是如何才能做到這一點? (對不起我的英文不好)
sd_webimages庫是下載圖像的最佳途徑。它也支持指標。 – Vahid
謝謝。它是完美的工作! :D – SwiftyIso
好吧,如果我的照片來到零,我想展現我自己的形象。 那麼我怎樣才能做到這一點與sd_webimages? – SwiftyIso