diff --git a/DEMO/DWCoreTextLabel.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/DEMO/DWCoreTextLabel.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/DEMO/DWCoreTextLabel.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/DEMO/DWCoreTextLabel.xcodeproj/project.xcworkspace/xcuserdata/zhangdingwen.xcuserdatad/UserInterfaceState.xcuserstate b/DEMO/DWCoreTextLabel.xcodeproj/project.xcworkspace/xcuserdata/zhangdingwen.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..21e99a1 Binary files /dev/null and b/DEMO/DWCoreTextLabel.xcodeproj/project.xcworkspace/xcuserdata/zhangdingwen.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/DEMO/DWCoreTextLabel.xcodeproj/xcuserdata/zhangdingwen.xcuserdatad/xcschemes/xcschememanagement.plist b/DEMO/DWCoreTextLabel.xcodeproj/xcuserdata/zhangdingwen.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..abb1938 --- /dev/null +++ b/DEMO/DWCoreTextLabel.xcodeproj/xcuserdata/zhangdingwen.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,14 @@ + + + + + SchemeUserState + + DWCoreTextLabel.xcscheme + + orderHint + 0 + + + + diff --git a/DWCoreTextLabel.podspec b/DWCoreTextLabel.podspec index bf597de..7133fe2 100755 --- a/DWCoreTextLabel.podspec +++ b/DWCoreTextLabel.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'DWCoreTextLabel' -s.version = '1.2.3' +s.version = '1.2.4' s.license = { :type => 'MIT', :file => 'LICENSE' } s.summary = 'It is a Label based on coreText,help you to layout of the collocation of illustration and character.基于coreText的Label控件,帮助你做图文混排。' s.homepage = 'https://github.com/CodeWicky/DWCoreTextLabel' diff --git a/DWCoreTextLabel/DWCoreTextLabel.h b/DWCoreTextLabel/DWCoreTextLabel.h index d91ea2c..bf1f26b 100644 --- a/DWCoreTextLabel/DWCoreTextLabel.h +++ b/DWCoreTextLabel/DWCoreTextLabel.h @@ -155,6 +155,12 @@ 少数情况末尾省略号失效,尚未找到原因 + version 1.2.3 + 规范Block写法 + + version 1.2.4 + 修改图片下载类 + */ #import diff --git a/DWCoreTextLabel/DWWebImage.h b/DWCoreTextLabel/DWWebImage.h index 1d32162..4b8544f 100644 --- a/DWCoreTextLabel/DWWebImage.h +++ b/DWCoreTextLabel/DWWebImage.h @@ -11,9 +11,16 @@ 轻量级图片异步下载缓存类 version 1.0.0 - 提供异步下载功能,提供图片缓存功能,线程安全。 + 提供异步下载功能,提供图片缓存功能。 + + version 1.0.1 + 添加断言 + + version 1.0.2 + 下载完成后修改operation为finish状态 */ + #import #ifndef DWWebImageMarco @@ -124,8 +131,18 @@ typedef NS_ENUM(NSUInteger, DWWebImageCacheType) {///缓存数据类型 ///现在完成标志 @property (nonatomic ,assign) BOOL downloadFinish; +///初始化方法 +-(instancetype)initWithSession:(NSURLSession *)session; + ///以url下载图片 -(void)downloadImageWithUrlString:(NSString *)url; + +///开启下载 +-(void)resume; + +///取消下载 +-(void)cancel; + @end @@ -136,6 +153,9 @@ typedef NS_ENUM(NSUInteger, DWWebImageCacheType) {///缓存数据类型 ///图片下载器 @property (nonatomic ,strong) DWWebImageDownloader * donwloader; +///下载任务是否完成 +@property (nonatomic , assign, getter=isFinished) BOOL finished; + ///以url及session下载图片 -(instancetype)initWithUrl:(NSString *)url session:(NSURLSession *)session; diff --git a/DWCoreTextLabel/DWWebImage.m b/DWCoreTextLabel/DWWebImage.m index 53ba112..8fe5f2a 100644 --- a/DWCoreTextLabel/DWWebImage.m +++ b/DWCoreTextLabel/DWWebImage.m @@ -148,6 +148,10 @@ -(void)downloadFinishNotice:(NSNotification *)sender if (error) {///移除任务 [self removeOperationByUrl:sender.userInfo[@"url"]]; [self removeCacheByUrl:sender.userInfo[@"url"]]; + } else { + NSString * url = sender.userInfo[@"url"]; + DWWebImageOperation * operation = self.operations[url];///取出下载任务 + operation.finished = YES; } } @@ -242,17 +246,24 @@ @interface DWWebImageDownloader () @implementation DWWebImageDownloader #pragma mark --- 接口方法 --- --(instancetype)initWithUrl:(NSString *)url session:(NSURLSession *)session -{ +-(instancetype)initWithSession:(NSURLSession *)session { self = [super init]; if (self) { - _url = url; _session = session; _downloadFinish = NO; } return self; } +-(instancetype)initWithUrl:(NSString *)url session:(NSURLSession *)session +{ + self = [self initWithSession:session]; + if (self) { + _url = url; + } + return self; +} + -(void)downloadImageWithUrlString:(NSString *)url { if (!url.length) { @@ -264,6 +275,14 @@ -(void)downloadImageWithUrlString:(NSString *)url [self downloadImageWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]]; } +-(void)resume { + [self.task resume]; +} + +-(void)cancel { + [self.task cancel]; +} + #pragma mark --- Tool Method --- -(void)downloadImageWithRequest:(NSURLRequest *)request { @@ -326,7 +345,7 @@ -(void)downloadImageWithRequest:(NSURLRequest *)request #pragma mark --- DWWebImageOperation --- @implementation DWWebImageOperation - +@synthesize finished = _finished; -(instancetype)initWithUrl:(NSString *)url session:(NSURLSession *)session { self = [super init]; @@ -340,13 +359,19 @@ -(instancetype)initWithUrl:(NSString *)url session:(NSURLSession *)session -(void)start { [super start]; - [self.donwloader.task resume]; + [self.donwloader resume]; } -(void)cancel { [super cancel]; - [self.donwloader.task cancel]; + [self.donwloader cancel]; +} + +-(void)setFinished:(BOOL)finished { + [self willChangeValueForKey:@"isFinished"]; + _finished = finished; + [self didChangeValueForKey:@"isFinished"]; } @end