Loading/Downloading image from URL on Swift

前端 未结 30 2579
感动是毒
感动是毒 2020-11-21 05:39

I\'d like to load an image from a URL in my application, so I first tried with Objective-C and it worked, however, with Swift, I\'ve a compilation error:

30条回答
  •  滥情空心
    2020-11-21 06:08

    Kingfisher is one of the best library for load image into URL.

    Github URL - https://github.com/onevcat/Kingfisher

    // If you want to use Activity Indicator.
    imageview_pic.kf.indicatorType = .activity
    imageview_pic.kf.setImage(with: URL(string: "Give your url string"))
    
    // If you want to use custom placeholder image.
    imageview_pic.kf.setImage(with: URL(string: "Give your url string"), placeholder: UIImage(named: "placeholder image name"), options: nil, progressBlock: nil, completionHandler: nil)
    

提交回复
热议问题