Skip to content

Latest commit

 

History

History
executable file
·
44 lines (35 loc) · 1.22 KB

Rabbit.md

File metadata and controls

executable file
·
44 lines (35 loc) · 1.22 KB

YsSwift/Rabbit

Ligtly and extensional library for downloading and caching images from the web, likes Nuke.



Usage

More features, read Demo

Base Features

//loading iamge from web
 self.imageView.ys.loadImage(with: URL(string: "your webimage url")!)

or add a placeholder image like this

self.imageView.ys.loadImage(with: URL(string: "your webimage url")!, placeholder: UIImage(named:"rabbit_1"))

Advance Features

Downloading web image for any objects becomes easy with Rabbit. For example make UIButton has this capability.

extension UIButton : YsSwift.Target {
    
    public func handle(response: Result<Image, YsSwift.RequestError>, isFromMemoryCache: Bool) {
        guard let image = response.value else { return }
        self.setImage(image, for: .normal)
    }
}

then use API from Rabbit to dowload image for UIButton

Rabbit.loadImage(with: URL(string: "your webimage url")!, into: self.button)

Thanks

Thank @kean, this project copy some code from Nuke