Good day everybody!)
This is a category to SDWebImage that offer you to add ProgressView in three ways:
- Circular (using DACircularProgress)
- Linear
- Custom
Images are downloading by SDWebImage (3.7.0 and up)
pod 'SDWebImage-CircularProgressView'
There are two parameters and unique prefix to easier finding.
progressViewType
- LinearPV or CircularPV. Choose the type of Progress View.progressView
- If you init your own UIProgressView than put it there. It should be a class or subclass of UIProgressView.
- (void)nkv_setImageWithURL:(NSURL *)url usingProgressViewType:(ProgressViewType)progressViewType orCustomProgressView:(UIProgressView *)progressView;
- (void)nkv_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder usingProgressViewType:(ProgressViewType)progressViewType orCustomProgressView:(UIProgressView *)progressView;
- (void)nkv_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options usingProgressViewType:(ProgressViewType)progressViewType orCustomProgressView:(UIProgressView *)progressView;
- (void)nkv_setImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock usingProgressViewType:(ProgressViewType)progressViewType orCustomProgressView:(UIProgressView *)progressView;
- (void)nkv_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock usingProgressViewType:(ProgressViewType)progressViewType orCustomProgressView:(UIProgressView *)progressView;
- (void)nkv_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock usingProgressViewType:(ProgressViewType)progressViewType orCustomProgressView:(UIProgressView *)progressView;
- (void)nkv_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock usingProgressViewType:(ProgressViewType)progressViewType orCustomProgressView:(UIProgressView *)progressView;
If you're using the sd_cancelCurrentImageLoad method
, you'll also have to call removeProgressView.
- (void)prepareForReuse {
[super prepareForReuse];
[self.imageView sd_cancelCurrentImageLoad];
[self.imageView removeProgressView];
}
#import "UIImageView+CircularProgressView.h"
@interface NKVTableCell () <ProgressViewDataSource>
[self.bodyImageV nkvSetProgressViewDataSource:self];
[self.bodyImageV nkv_setImageWithURL:url usingProgressViewType:CircularPV orCustomProgressView:nil];
- In self (DataSource's class) implement method:
- (CircularProgressViewSettings *)setupCircularProgressViewSettings
{
CircularProgressViewSettings *circularSettings = [CircularProgressViewSettings new];
circularSettings.progressTintColor = [UIColor redColor];
circularSettings.thicknessRatio = 0.2;
return circularSettings;
}
[DACircularProgressView appearance].trackTintColor = [UIColor lightGrayColor];
[DACircularProgressView appearance].progressTintColor = [UIColor blackColor];
[UIProgressView appearance].trackTintColor = [UIColor lightGrayColor];
[UIProgressView appearance].progressTintColor = [UIColor blackColor];
- It uses SDWebImage and DACircularProgress.
- CirclePV type implements transparent view by default. Use appearance in AppDelegate or somewhere else to customize it.
- Custom progress bar is a priority for other types. Otherwords if you choose
LinearPV
and then addorCustomProgressView:(UIProgressView*)yourCustomProgressView
than it would be your custom ProgressView.
Inspired by projects:
- https://github.com/kevinrenskers/SDWebImage-ProgressView
- https://github.com/danielamitay/DACircularProgress
- Add http://shields.io/
- Add example
- Add UIedgeInsets like property
- Add refresh button to image
- Think about default settings for CircleV
- https://github.com/NikKovIos/ObjectMapper_RealmSwift - extension to add Realm object support for ObjectMapper
- https://github.com/NikKovIos/NKVPhonePicker - UITextField subclass picker for country phone codes