No Description

UIImageView+XHURLDownload.h 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //
  2. // UIImageView+XHURLDownload.h
  3. // XHImageViewer
  4. //
  5. // Created by 曾 宪华 on 14-2-18.
  6. // Copyright (c) 2014年 曾宪华 开发团队(http://iyilunba.com ) 本人QQ:543413507 本人QQ群(142557668). All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. typedef NS_ENUM(NSInteger, UIImageViewURLDownloadState) {
  10. UIImageViewURLDownloadStateUnknown = 0,
  11. UIImageViewURLDownloadStateLoaded,
  12. UIImageViewURLDownloadStateWaitingForLoad,
  13. UIImageViewURLDownloadStateNowLoading,
  14. UIImageViewURLDownloadStateFailed,
  15. };
  16. @interface UIImageView (XHURLDownload)
  17. // url
  18. @property (nonatomic, strong) NSURL *url;
  19. // download state
  20. @property (nonatomic, readonly) UIImageViewURLDownloadState loadingState;
  21. // UI
  22. @property (nonatomic, strong) UIView *loadingView;
  23. // Set UIActivityIndicatorView as loadingView
  24. - (void)setDefaultLoadingView;
  25. // instancetype
  26. + (id)imageViewWithURL:(NSURL*)url autoLoading:(BOOL)autoLoading;
  27. // Get instance that has UIActivityIndicatorView as loadingView by default
  28. + (id)indicatorImageView;
  29. + (id)indicatorImageViewWithURL:(NSURL*)url autoLoading:(BOOL)autoLoading;
  30. // Download
  31. - (void)setUrl:(NSURL *)url autoLoading:(BOOL)autoLoading;
  32. - (void)load;
  33. - (void)loadWithURL:(NSURL *)url;
  34. - (void)loadWithURL:(NSURL*)url completionBlock:(void(^)(UIImage *image, NSURL *url, NSError *error))handler;
  35. @end