diff --git a/GKPhotoBrowser/Core/GKPhotoBrowser.m b/GKPhotoBrowser/Core/GKPhotoBrowser.m index 839b9fc9..1928e3a0 100644 --- a/GKPhotoBrowser/Core/GKPhotoBrowser.m +++ b/GKPhotoBrowser/Core/GKPhotoBrowser.m @@ -429,7 +429,7 @@ - (void)layoutSubviews { }else { CGFloat centerX = self.contentView.bounds.size.width * 0.5f; - self.countLabel.center = CGPointMake(centerX, (KIsiPhoneX && !self.isLandscape) ? 50 : 30); + self.countLabel.center = CGPointMake(centerX, (KIsiPhoneX && !self.isLandscape) ? 65 : 30); CGFloat pointY = 0; if (self.isLandscape) { pointY = self.contentView.bounds.size.height - 20; @@ -437,7 +437,7 @@ - (void)layoutSubviews { pointY = self.contentView.bounds.size.height - 10 - (self.isAdaptiveSafeArea ? 0 : kSafeBottomSpace); } self.pageControl.center = CGPointMake(centerX, pointY); - self.saveBtn.center = CGPointMake(self.contentView.bounds.size.width - 50, pointY); + self.saveBtn.center = CGPointMake(self.contentView.bounds.size.width - 30, pointY - 10); } if ([self.delegate respondsToSelector:@selector(photoBrowser:willLayoutSubViews:)]) { @@ -1416,14 +1416,8 @@ - (UIPageControl *)pageControl { - (UIButton *)saveBtn { if (!_saveBtn) { UIButton *saveBtn = [UIButton new]; - saveBtn.bounds = CGRectMake(0, 0, 50, 30); - [saveBtn setTitle:@"保存" forState:UIControlStateNormal]; - [saveBtn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal]; - saveBtn.titleLabel.font = [UIFont systemFontOfSize:15.0f]; - saveBtn.layer.cornerRadius = 5; - saveBtn.layer.masksToBounds = YES; - saveBtn.layer.borderColor = UIColor.whiteColor.CGColor; - saveBtn.layer.borderWidth = 1; + saveBtn.bounds = CGRectMake(0, 0, 20, 20); + [saveBtn setBackgroundImage:GKPhotoBrowserImage(@"icon_download") forState:UIControlStateNormal]; saveBtn.hidden = YES; [saveBtn addTarget:self action:@selector(saveBtnClick:) forControlEvents:UIControlEventTouchUpInside]; _saveBtn = saveBtn; diff --git a/GKPhotoBrowser/Core/GKPhotoManager.h b/GKPhotoBrowser/Core/GKPhotoManager.h index 4e98979a..58913ab8 100644 --- a/GKPhotoBrowser/Core/GKPhotoManager.h +++ b/GKPhotoBrowser/Core/GKPhotoManager.h @@ -35,6 +35,12 @@ NS_ASSUME_NONNULL_BEGIN /** 占位图 */ @property (nonatomic, strong, nullable) UIImage *placeholderImage; +/** originUrl 权限header */ +@property (nonatomic, strong, nullable) NSDictionary *originAuthToken; + +/** url 权限header */ +@property (nonatomic, strong, nullable) NSDictionary *authToken; + /************************内部使用,无需关心 ********************/ /** 图片是否加载完成 */ diff --git a/GKPhotoBrowser/Core/GKPhotoView.m b/GKPhotoBrowser/Core/GKPhotoView.m index 9b97caf0..31b9bac1 100644 --- a/GKPhotoBrowser/Core/GKPhotoView.m +++ b/GKPhotoBrowser/Core/GKPhotoView.m @@ -200,10 +200,13 @@ - (void)loadImageWithPhoto:(GKPhoto *)photo isOrigin:(BOOL)isOrigin { } NSURL *url = nil; + NSDictionary *authToken = nil; if (photo.originFinished) { url = photo.originUrl; + authToken = photo.originAuthToken; }else { url = isOrigin ? photo.originUrl : photo.url; + authToken = isOrigin ? photo.originAuthToken : photo.authToken; } if (url.absoluteString.length > 0) { @@ -269,7 +272,7 @@ - (void)loadImageWithPhoto:(GKPhoto *)photo isOrigin:(BOOL)isOrigin { }); }; - [_imageProtocol setImageForImageView:self.imageView url:url placeholderImage:placeholderImage progress:progressBlock completion:completionBlock]; + [_imageProtocol setImageForImageView:self.imageView url:url authToken:authToken placeholderImage:placeholderImage progress:progressBlock completion:completionBlock]; }else { if (self.imageView.image) { photo.finished = YES; diff --git a/GKPhotoBrowser/Core/GKWebImageProtocol.h b/GKPhotoBrowser/Core/GKWebImageProtocol.h index 880c0309..6bd05326 100644 --- a/GKPhotoBrowser/Core/GKWebImageProtocol.h +++ b/GKPhotoBrowser/Core/GKWebImageProtocol.h @@ -20,11 +20,13 @@ typedef void (^GKWebImageCompletionBlock)(UIImage * _Nullable image, NSURL * _Nu /// 为imageView设置图片 /// @param imageView imageView /// @param url 图片url +/// @param auth 图片的权限 /// @param placeholderImage 缺省图片 /// @param progressBlock 加载进度 /// @param completionBlock 完成进度 - (void)setImageForImageView:(nullable UIImageView *)imageView url:(nullable NSURL *)url + authToken:(nullable NSDictionary *)auth placeholderImage:(nullable UIImage *)placeholderImage progress:(nullable GKWebImageProgressBlock)progressBlock completion:(nullable GKWebImageCompletionBlock)completionBlock; diff --git a/GKPhotoBrowser/GKPhotoBrowser.bundle/icon_download.png b/GKPhotoBrowser/GKPhotoBrowser.bundle/icon_download.png new file mode 100644 index 00000000..90b712cd Binary files /dev/null and b/GKPhotoBrowser/GKPhotoBrowser.bundle/icon_download.png differ diff --git a/GKPhotoBrowser/GKPhotoBrowser.bundle/icon_download@2x.png b/GKPhotoBrowser/GKPhotoBrowser.bundle/icon_download@2x.png new file mode 100644 index 00000000..90b712cd Binary files /dev/null and b/GKPhotoBrowser/GKPhotoBrowser.bundle/icon_download@2x.png differ diff --git a/GKPhotoBrowser/GKPhotoBrowser.bundle/icon_download@3x.png b/GKPhotoBrowser/GKPhotoBrowser.bundle/icon_download@3x.png new file mode 100644 index 00000000..90b712cd Binary files /dev/null and b/GKPhotoBrowser/GKPhotoBrowser.bundle/icon_download@3x.png differ diff --git a/GKPhotoBrowser/SDWebImage/GKSDWebImageManager.m b/GKPhotoBrowser/SDWebImage/GKSDWebImageManager.m index 13c394cc..76464af7 100644 --- a/GKPhotoBrowser/SDWebImage/GKSDWebImageManager.m +++ b/GKPhotoBrowser/SDWebImage/GKSDWebImageManager.m @@ -29,7 +29,13 @@ - (Class)imageViewClass { return SDAnimatedImageView.class; } -- (void)setImageForImageView:(UIImageView *)imageView url:(NSURL *)url placeholderImage:(UIImage *)placeholderImage progress:(GKWebImageProgressBlock)progress completion:(GKWebImageCompletionBlock)completion { +- (void)setImageForImageView:(UIImageView *)imageView url:(NSURL *)url authToken:(NSDictionary *)token placeholderImage:(UIImage *)placeholderImage progress:(GKWebImageProgressBlock)progress completion:(GKWebImageCompletionBlock)completion { + + SDWebImageDownloader *manager = [SDWebImageManager sharedManager].imageLoader; + for (NSString *key in token) { + [manager setValue:[token objectForKey:key] forHTTPHeaderField:key]; + } + [imageView sd_setImageWithURL:url placeholderImage:placeholderImage options:SDWebImageRetryFailed progress:^(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL) { !progress ? : progress(receivedSize, expectedSize); } completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {