Latest | 0.4.0 |
---|---|
Homepage | https://github.com/buildo/GPAvatarView |
License | MIT |
Platforms | ios 8.0, requires ARC |
Dependencies | SDWebImage |
Frameworks | Foundation, UIKit |
Authors |
A deadly simple UIView
subclass for rounded corners lazy-loaded images.
Pure swift code.
It loads and renders a UIImage
lazyily from a URL, optionally specifying a placeholder image.
Interface Builder support
You can use GPAvatarImage
directly from Interface Builder, dragging a UIView
into your view hierarchy and chaning its class to GPAvatarImage
. The view is fully compliant with Xcode 6 Live Rendering feature, so you can preview the image and set a placeholder directly from IB.
Needless to say, you can otherwise use this component programmatically.
API
There’s a single method you can call:
func setImageWithURL(
URL: NSURL,
placeholder: UIImage? = nil,
completionHandler:((UIImage!, NSError?) -> Void)? = nil
)
as you see the only required parameter is URL
. placeholder
and completionHandler
are optional.
Quick example
let url = NSURL(string: "https://example.com/foo.jpg")
let placeholder = UIImage(named: "placeholder")
avatarView.setImageWithURL(url, placeholder: placeholder) { (image, error) in
if let e = error {
println("Houston, we have a problem: (e)")
} else {
// do whatever you like with your damn image
}
}
Credits
- SDWebImage for async image loading
Latest podspec
{ "name": "GPAvatarView", "version": "0.4.0", "license": { "type": "MIT", "file": "LICENSE" }, "summary": "A dead simple UIView subclass for rounded corners images", "homepage": "https://github.com/buildo/GPAvatarView", "social_media_url": "http://twitter.com/gabro27", "authors": { "Gabriele Petronella": "[email protected]" }, "platforms": { "ios": "8.0" }, "source": { "git": "https://github.com/buildo/GPAvatarView.git", "tag": "v0.4.0" }, "source_files": "GPAvatarView/GPAvatarView.swift", "frameworks": [ "Foundation", "UIKit" ], "requires_arc": true, "dependencies": { "SDWebImage": [ "~> 3.7.1" ] }, "pushed_with_swift_version": "3.0" }
Fri, 28 Oct 2016 01:20:03 +0000