How to load image in swift using Alamofire

后端 未结 9 1045
醉话见心
醉话见心 2020-12-13 13:16

I have a collection view controller, which load image Async by URL. (Something like Instegram) I am looking for the best way to implement the part of the loading image. plea

9条回答
  •  忘掉有多难
    2020-12-13 14:01

    In swift 5 & Alamofire 5,You can use like bellow..

      AF.request( "https://robohash.org/123.png",method: .get).response{ response in
    
       switch response.result {
        case .success(let responseData):
            self.myImageView.image = UIImage(data: responseData!, scale:1)
    
        case .failure(let error):
            print("error--->",error)
        }
    }
    

提交回复
热议问题