NZCircularImageView is a UIImageView extension. Its performs async download image and leaves with rounded edge.
It can be used, for example, to presenting pictures of user profiles.
NZCircularImageView works on iOS 5.0+ version and is compatible with ARC projects. It depends on the following Apple frameworks, which should already be included with most Xcode templates:
- Foundation.framework
- QuartzCore.framework
- UIKit.framework
You will need LLVM 3.0 or later in order to build NZCircularImageView.
NZCircularImageView uses SDWebImage and UIActivityIndicator-for-SDWebImage to download async images.
CocoaPods is the recommended way to add NZCircularImageView to your project.
- Add a pod entry for NZCircularImageView to your Podfile
pod 'NZCircularImageView', '~> 0.0.2'
- Install the pod(s) by running
pod install
.
Alternatively you can directly add source files to your project.
- Download the latest code version or add the repository as a git submodule to your git-tracked project.
- Open your project in Xcode, then drag and drop all files at
NZCircularImageView
folder onto your project (use the "Product Navigator view"). Make sure to select Copy items when asked if you extracted the code archive outside of your project. - Install SDWebImage
- Install UIActivityIndicator-for-SDWebImage
The class overrides -(void)setFrame:
, thus ensuring that every time an image is set, it will be presented in a rounded shape.
This class also uses UIViewContentModeScaleAspectFill
contentMode with the clipsToBounds
flag so that the image resolution is not changed.
- Setting at Storyboard to automatic rounded image
- Setting a rounded avatar image
circularImageView.image = [UIImage imageNamed:@"Default-Avatar"];
- Async download image
// this method append parameters at url:
// - width: image view width
// - height: image view height
// - mode: crop (crop image from center)
[circularImageView setImageWithResizeURL:@"http://example.com/image.png"];
//
// ... with custom loading indicator
[circularImageView setImageWithResizeURL:kImageUrl
usingActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
//
// ... with completion block
[circularImageView setImageWithResizeURL:kImageUrl
usingActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) {
NSLog(@"Download completed");
}];
To enable the logs in debug/release mode, add #define NZDEBUG
at *-Prefix.pch
file in your project.
This code is distributed under the terms and conditions of the MIT license.
A brief summary of each NZCircularImageView release can be found on the wiki.