From 45a5a38a2a8ff1f420efb8f50ba94c80e6c3d5a0 Mon Sep 17 00:00:00 2001 From: fengshuo <963787902@qq.com> Date: Mon, 27 Sep 2021 11:15:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E4=B8=AA=E4=BA=BA?= =?UTF-8?q?=E8=B5=84=E6=96=99=E9=A1=B5=E7=9A=84=E8=92=99=E7=89=88=E7=9A=84?= =?UTF-8?q?=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xplan-ios.xcodeproj/project.pbxproj | 30 +- .../Base/UI/UIImageView/UIImageConstant.h | 9 +- .../Base/UI/UIImageView/UIImageConstant.m | 14 +- .../UI/UIImageView/UIImageView+LoadImage.h | 24 +- .../UI/UIImageView/UIImageView+LoadImage.m | 33 ++- .../UI/VagueImageView/UIImage+ImageEffects.h | 107 +++++++ .../UI/VagueImageView/UIImage+ImageEffects.m | 278 ++++++++++++++++++ .../UI/VagueImageView/UIImageView+Vague.h | 20 ++ .../UI/VagueImageView/UIImageView+Vague.m | 34 +++ .../XPMineUserInfoAlbumCollectionViewCell.m | 2 +- .../XPMineUserInfoEditTableViewCell.m | 4 +- .../XPMineUserInfoAlbumViewController.m | 2 +- .../MineInfo/XPMineUserInfoViewController.h | 4 +- .../MineInfo/XPMineUserInfoViewController.m | 18 +- .../MineInfo/XPMineUserInfoCustomNavView.h | 0 .../MineInfo/XPMineUserInfoCustomNavView.m | 0 .../MineInfo/XPMineUserInfoHeaderView.h | 4 +- .../MineInfo/XPMineUserInfoHeaderView.m | 86 ++++-- .../SubViews/MineInfo/XPMineUserTableView.h | 16 + .../SubViews/MineInfo/XPMineUserTableView.m | 22 ++ .../Main/Mine/View/SubViews/XPMineHeadView.m | 2 +- 21 files changed, 637 insertions(+), 72 deletions(-) create mode 100755 xplan-ios/Base/UI/VagueImageView/UIImage+ImageEffects.h create mode 100755 xplan-ios/Base/UI/VagueImageView/UIImage+ImageEffects.m create mode 100644 xplan-ios/Base/UI/VagueImageView/UIImageView+Vague.h create mode 100644 xplan-ios/Base/UI/VagueImageView/UIImageView+Vague.m rename xplan-ios/Main/Mine/View/{Cell => SubViews}/MineInfo/XPMineUserInfoCustomNavView.h (100%) rename xplan-ios/Main/Mine/View/{Cell => SubViews}/MineInfo/XPMineUserInfoCustomNavView.m (100%) create mode 100644 xplan-ios/Main/Mine/View/SubViews/MineInfo/XPMineUserTableView.h create mode 100644 xplan-ios/Main/Mine/View/SubViews/MineInfo/XPMineUserTableView.m diff --git a/xplan-ios.xcodeproj/project.pbxproj b/xplan-ios.xcodeproj/project.pbxproj index 71cd5268..0266c9b2 100644 --- a/xplan-ios.xcodeproj/project.pbxproj +++ b/xplan-ios.xcodeproj/project.pbxproj @@ -121,6 +121,9 @@ E824546126F5F4E400BE8163 /* XPMineResetPayPwdViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E824546026F5F4E400BE8163 /* XPMineResetPayPwdViewController.m */; }; E824546426F5FF1C00BE8163 /* XPMineResetPayPasswordPresenter.m in Sources */ = {isa = PBXBuildFile; fileRef = E824546326F5FF1C00BE8163 /* XPMineResetPayPasswordPresenter.m */; }; E824546626F5FF6000BE8163 /* XPMineResetPayPasswordProtocol.h in Sources */ = {isa = PBXBuildFile; fileRef = E824546526F5FF5100BE8163 /* XPMineResetPayPasswordProtocol.h */; }; + E865963F27015A9C00846EBD /* XPMineUserTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = E865963E27015A9C00846EBD /* XPMineUserTableView.m */; }; + E86596432701611A00846EBD /* UIImage+ImageEffects.m in Sources */ = {isa = PBXBuildFile; fileRef = E86596412701611A00846EBD /* UIImage+ImageEffects.m */; }; + E86596462701612D00846EBD /* UIImageView+Vague.m in Sources */ = {isa = PBXBuildFile; fileRef = E86596452701612D00846EBD /* UIImageView+Vague.m */; }; E872308926E89BE000B90D4F /* LoginPhoneViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E872308826E89BE000B90D4F /* LoginPhoneViewController.m */; }; E872308D26E89DAA00B90D4F /* LoginInputView.m in Sources */ = {isa = PBXBuildFile; fileRef = E872308C26E89DAA00B90D4F /* LoginInputView.m */; }; E872309326E8D31500B90D4F /* LoginVerifCodeView.m in Sources */ = {isa = PBXBuildFile; fileRef = E872309226E8D31500B90D4F /* LoginVerifCodeView.m */; }; @@ -421,6 +424,12 @@ E824546226F5FF1C00BE8163 /* XPMineResetPayPasswordPresenter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineResetPayPasswordPresenter.h; sourceTree = ""; }; E824546326F5FF1C00BE8163 /* XPMineResetPayPasswordPresenter.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMineResetPayPasswordPresenter.m; sourceTree = ""; }; E824546526F5FF5100BE8163 /* XPMineResetPayPasswordProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineResetPayPasswordProtocol.h; sourceTree = ""; }; + E865963D27015A9C00846EBD /* XPMineUserTableView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineUserTableView.h; sourceTree = ""; }; + E865963E27015A9C00846EBD /* XPMineUserTableView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMineUserTableView.m; sourceTree = ""; }; + E86596412701611A00846EBD /* UIImage+ImageEffects.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+ImageEffects.m"; sourceTree = ""; }; + E86596422701611A00846EBD /* UIImage+ImageEffects.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+ImageEffects.h"; sourceTree = ""; }; + E86596442701612D00846EBD /* UIImageView+Vague.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIImageView+Vague.h"; sourceTree = ""; }; + E86596452701612D00846EBD /* UIImageView+Vague.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIImageView+Vague.m"; sourceTree = ""; }; E872308726E89BE000B90D4F /* LoginPhoneViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LoginPhoneViewController.h; sourceTree = ""; }; E872308826E89BE000B90D4F /* LoginPhoneViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LoginPhoneViewController.m; sourceTree = ""; }; E872308B26E89DAA00B90D4F /* LoginInputView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LoginInputView.h; sourceTree = ""; }; @@ -874,6 +883,7 @@ 189DD56C26DF5B5400AB55B1 /* UI */ = { isa = PBXGroup; children = ( + E8659640270160F200846EBD /* VagueImageView */, E8AC720A26F435AF007D6E91 /* UIImageView */, E81366F926F0D27A0076364C /* UIButton */, E82109B126F2050D00FC3319 /* UIImage */, @@ -1164,6 +1174,17 @@ path = UIImage; sourceTree = ""; }; + E8659640270160F200846EBD /* VagueImageView */ = { + isa = PBXGroup; + children = ( + E86596422701611A00846EBD /* UIImage+ImageEffects.h */, + E86596412701611A00846EBD /* UIImage+ImageEffects.m */, + E86596442701612D00846EBD /* UIImageView+Vague.h */, + E86596452701612D00846EBD /* UIImageView+Vague.m */, + ); + path = VagueImageView; + sourceTree = ""; + }; E872308A26E89D5100B90D4F /* CustomView */ = { isa = PBXGroup; children = ( @@ -1223,10 +1244,14 @@ E88B5CC226FB429C00DA9178 /* MineInfo */ = { isa = PBXGroup; children = ( + E8EEB8FC26FC2DF8007C6EBA /* XPMineUserInfoCustomNavView.h */, + E8EEB8FD26FC2DF8007C6EBA /* XPMineUserInfoCustomNavView.m */, E88B5CC326FB42B000DA9178 /* XPMineUserInfoHeaderView.h */, E88B5CC426FB42B000DA9178 /* XPMineUserInfoHeaderView.m */, E8EEB91B26FC9D58007C6EBA /* XPMineUserInfoDateView.h */, E8EEB91C26FC9D58007C6EBA /* XPMineUserInfoDateView.m */, + E865963D27015A9C00846EBD /* XPMineUserTableView.h */, + E865963E27015A9C00846EBD /* XPMineUserTableView.m */, ); path = MineInfo; sourceTree = ""; @@ -1503,8 +1528,6 @@ children = ( E8EEB8F926FC2874007C6EBA /* XPMineUserInfoTableViewCell.h */, E8EEB8FA26FC2874007C6EBA /* XPMineUserInfoTableViewCell.m */, - E8EEB8FC26FC2DF8007C6EBA /* XPMineUserInfoCustomNavView.h */, - E8EEB8FD26FC2DF8007C6EBA /* XPMineUserInfoCustomNavView.m */, E8EEB90726FC579A007C6EBA /* XPMineUserInfoEditTableViewCell.h */, E8EEB90826FC579A007C6EBA /* XPMineUserInfoEditTableViewCell.m */, E8B846C026FD82DC00A777FE /* XPMineUserInfoAlbumCollectionViewCell.h */, @@ -1673,6 +1696,7 @@ E88B5CB526FB20B800DA9178 /* XPMineTeenagerPwdView.m in Sources */, E81C279826EB3AC40031E639 /* LoginForgetPasswordProtocol.h in Sources */, E82109B026F1D83500FC3319 /* LoginBindPhonePresent.m in Sources */, + E865963F27015A9C00846EBD /* XPMineUserTableView.m in Sources */, E8B825C726EA0D9A009E8E9F /* LoginVerifCodeProtocol.h in Sources */, E824544E26F5BC1A00BE8163 /* XPMineModifPayPwdView.m in Sources */, E8B825CA26EA1231009E8E9F /* LoginVerifCodeViewController.m in Sources */, @@ -1738,6 +1762,7 @@ 186A534B26FC6ED900D67B2C /* TTPopupManagerService.m in Sources */, 18E7B1B226E8AF980064BC9B /* MainPresenter.m in Sources */, E81366F626F0C0DF0076364C /* LoginFullInfoPresenter.m in Sources */, + E86596462701612D00846EBD /* UIImageView+Vague.m in Sources */, 189DD67E26E1FD8900AB55B1 /* UIImage+Utils.m in Sources */, E824545626F5E51900BE8163 /* XPMineVerifIdentityViewController.m in Sources */, 186A534726FC6ED900D67B2C /* TTAlertConfig.m in Sources */, @@ -1750,6 +1775,7 @@ E8B825CD26EA18C8009E8E9F /* ThemeColor.m in Sources */, E8AC720D26F435F5007D6E91 /* UIImageView+LoadImage.m in Sources */, E88B5CBD26FB3BDF00DA9178 /* XPTeenagerAlertView.m in Sources */, + E86596432701611A00846EBD /* UIImage+ImageEffects.m in Sources */, E8CEA03D26EA3DE500644B44 /* LoginPasswordPresent.m in Sources */, E8E70D7726F2F15100F03460 /* XPMineViewController.m in Sources */, E8AC722C26F49580007D6E91 /* XPMineNotificaViewController.m in Sources */, diff --git a/xplan-ios/Base/UI/UIImageView/UIImageConstant.h b/xplan-ios/Base/UI/UIImageView/UIImageConstant.h index b45de71d..737ff645 100644 --- a/xplan-ios/Base/UI/UIImageView/UIImageConstant.h +++ b/xplan-ios/Base/UI/UIImageView/UIImageConstant.h @@ -18,7 +18,7 @@ UIKIT_EXTERN NSString * const kImageTypeRoomGift; //房间礼物 UIKIT_EXTERN NSString * const kImageTypeUserIcon; //用户头像60x60 UIKIT_EXTERN NSString * const kImageTypeUserLibaryDetail;//用户相册大图nil UIKIT_EXTERN NSString * const kImageTypeCornerAvatar;//圆角图形,会先把图形裁剪成正方形,并且转换为png - +UIKIT_EXTERN NSString * const kImageTypeUserInfoAlbum;//用户信息里面相册 typedef NS_ENUM(NSUInteger,ImageType){ ImageTypeRoomFace = 1, //房间表情 @@ -26,16 +26,17 @@ typedef NS_ENUM(NSUInteger,ImageType){ ImageTypeUserIcon, //用户头像60x60 ImageTypeUserLibaryDetail, //用户相册大图 ImageTypeCornerAvatar, //圆角图形,会先把图形裁剪成正方形,并且转换为png + ImageTypeUserInfoAlbum, ///用户信息里面相册 }; ///展位图 /// 头像的默认占位图 -+ (NSString *)defaultAvatarPlaceholder; ++ (UIImage *)defaultAvatarPlaceholder; /// 空白图的占位图 -+ (NSString *)defalutEmptyPlaceholder; ++ (UIImage *)defalutEmptyPlaceholder; /// banner的占位图 -+ (NSString *)defalutBannerPlaceholder; ++ (UIImage *)defalutBannerPlaceholder; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Base/UI/UIImageView/UIImageConstant.m b/xplan-ios/Base/UI/UIImageView/UIImageConstant.m index 27b0de71..5ce47a3b 100644 --- a/xplan-ios/Base/UI/UIImageView/UIImageConstant.m +++ b/xplan-ios/Base/UI/UIImageView/UIImageConstant.m @@ -15,18 +15,18 @@ NSString * const kImageTypeRoomGift = @""; NSString * const kImageTypeUserIcon = @"imageMogr2/auto-orient/thumbnail/150x150"; //用户头像150x150 NSString * const kImageTypeUserLibaryDetail = @"imageMogr2/auto-orient/thumbnail/300x300"; //用户相册大图nil NSString * const kImageTypeCornerAvatar = @"imageMogr2/auto-orient/thumbnail/300x300/format/png"; - +NSString * const kImageTypeUserInfoAlbum = @"imageMogr2/auto-orient/thumbnail/375x248"; ;//用户信息里面相册 /// 头像的默认占位图 -+ (NSString *)defaultAvatarPlaceholder { - return @"common_avatar"; ++ (UIImage *)defaultAvatarPlaceholder { + return [UIImage imageNamed:@"common_avatar"]; } /// 空白图的占位图 -+ (NSString *)defalutEmptyPlaceholder { - return @"common_empty"; ++ (UIImage *)defalutEmptyPlaceholder { + return [UIImage imageNamed:@"common_empty"]; } /// banner的占位图 -+ (NSString *)defalutBannerPlaceholder { - return @"common_banner"; ++ (UIImage *)defalutBannerPlaceholder { + return [UIImage imageNamed:@"common_banner"]; } @end diff --git a/xplan-ios/Base/UI/UIImageView/UIImageView+LoadImage.h b/xplan-ios/Base/UI/UIImageView/UIImageView+LoadImage.h index 8d6f73d2..6830175e 100644 --- a/xplan-ios/Base/UI/UIImageView/UIImageView+LoadImage.h +++ b/xplan-ios/Base/UI/UIImageView/UIImageView+LoadImage.h @@ -16,19 +16,25 @@ NS_ASSUME_NONNULL_BEGIN /// @param type 类型 用于设置大小 /// @param cornerRadious 弧度 /// @param success 成功的回调 -- (void)load_setImageImageWithUrl:(NSString *)url - placeholderImage:(NSString *)placeholderImage +- (void)load_imageWithUrl:(NSString *)url + placeholderImage:(UIImage *)placeholderImage type:(ImageType)type cornerRadious:(CGFloat)cornerRadious success:(void (^)(UIImage *image))success; +/// 加载图片 回调图片的 +/// @param url 图片的链接地址 +/// @param placeholderImage 站位图 +/// @param success 成功了 +- (void)load_imageWithUrl:(NSString *)url placeholderImage:(UIImage *)placeholderImage type:(ImageType)type success:(void (^)(UIImage *image))success; + /// 加载图片不需要成功的回调 /// @param url 图片的链接地址 /// @param placeholderImage 站位图 /// @param type 类型 用于设置大小 /// @param cornerRadious 弧度 -- (void)load_setImageImageWithUrl:(NSString *)url - placeholderImage:(NSString *)placeholderImage +- (void)load_imageWithUrl:(NSString *)url + placeholderImage:(UIImage *)placeholderImage type:(ImageType)type cornerRadious:(CGFloat)cornerRadious; @@ -36,18 +42,14 @@ NS_ASSUME_NONNULL_BEGIN /// @param url 图片的链接地址 /// @param placeholderImage 站位图 /// @param type 类型 用于设置大小 -- (void)load_setImageImageWithUrl:(NSString *)url placeholderImage:(NSString *)placeholderImage type:(ImageType)type; +- (void)load_imageWithUrl:(NSString *)url placeholderImage:(UIImage *)placeholderImage type:(ImageType)type; /// 加载图片 没有类型的设置 /// @param url 图片的链接地址 /// @param placeholderImage 站位图 -- (void)load_setImageImageWithUrl:(NSString *)url placeholderImage:(NSString *)placeholderImage; +- (void)load_imageWithUrl:(NSString *)url placeholderImage:(UIImage *)placeholderImage; + -/// 加载图片 回调图片的 -/// @param url 图片的链接地址 -/// @param placeholderImage 站位图 -/// @param success 成功了 -- (void)load_setImageImageWithUrl:(NSString *)url placeholderImage:(NSString *)placeholderImage success:(void (^)(UIImage *image))success; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Base/UI/UIImageView/UIImageView+LoadImage.m b/xplan-ios/Base/UI/UIImageView/UIImageView+LoadImage.m index e4231b76..e12f2c7e 100644 --- a/xplan-ios/Base/UI/UIImageView/UIImageView+LoadImage.m +++ b/xplan-ios/Base/UI/UIImageView/UIImageView+LoadImage.m @@ -17,8 +17,8 @@ /// @param type 类型 用于设置大小 /// @param cornerRadious 弧度 /// @param success 成功的回调 -- (void)load_setImageImageWithUrl:(NSString *)url - placeholderImage:(NSString *)placeholderImage +- (void)load_imageWithUrl:(NSString *)url + placeholderImage:(UIImage *)placeholderImage type:(ImageType)type cornerRadious:(CGFloat)cornerRadious success:(void (^)(UIImage *image))success { @@ -50,6 +50,11 @@ configUrl = kImageTypeRoomGift; } break; + case ImageTypeUserInfoAlbum: + { + configUrl = kImageTypeUserInfoAlbum; + } + break; default: break; } @@ -69,8 +74,8 @@ NSString *encodeStr = [self URLEncodedString:urlString]; - if (placeholderImage.length > 0) { - [self sd_setImageWithURL:[NSURL URLWithString:encodeStr] placeholderImage:[UIImage imageNamed:placeholderImage] options:SDWebImageRetryFailed completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { + if (placeholderImage) { + [self sd_setImageWithURL:[NSURL URLWithString:encodeStr] placeholderImage:placeholderImage options:SDWebImageRetryFailed completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { if (success) { success(image); } @@ -90,11 +95,11 @@ /// @param placeholderImage 站位图 /// @param type 类型 用于设置大小 /// @param cornerRadious 弧度 -- (void)load_setImageImageWithUrl:(NSString *)url - placeholderImage:(NSString *)placeholderImage +- (void)load_imageWithUrl:(NSString *)url + placeholderImage:(UIImage *)placeholderImage type:(ImageType)type cornerRadious:(CGFloat)cornerRadious { - [self load_setImageImageWithUrl:url placeholderImage:placeholderImage type:type cornerRadious:cornerRadious success:nil]; + [self load_imageWithUrl:url placeholderImage:placeholderImage type:type cornerRadious:cornerRadious success:nil]; } @@ -102,15 +107,15 @@ /// @param url 图片的链接地址 /// @param placeholderImage 站位图 /// @param type 类型 用于设置大小 -- (void)load_setImageImageWithUrl:(NSString *)url placeholderImage:(NSString *)placeholderImage type:(ImageType)type{ - [self load_setImageImageWithUrl:url placeholderImage:placeholderImage type:type cornerRadious:0]; +- (void)load_imageWithUrl:(NSString *)url placeholderImage:(UIImage *)placeholderImage type:(ImageType)type{ + [self load_imageWithUrl:url placeholderImage:placeholderImage type:type cornerRadious:0]; } /// 加载图片 没有类型的设置 /// @param url 图片的链接地址 /// @param placeholderImage 站位图 -- (void)load_setImageImageWithUrl:(NSString *)url placeholderImage:(NSString *)placeholderImage { - [self load_setImageImageWithUrl:url placeholderImage:placeholderImage type:0 cornerRadious:0]; +- (void)load_imageWithUrl:(NSString *)url placeholderImage:(UIImage *)placeholderImage { + [self load_imageWithUrl:url placeholderImage:placeholderImage type:0 cornerRadious:0]; } @@ -118,10 +123,8 @@ /// @param url 图片的链接地址 /// @param placeholderImage 站位图 /// @param success 成功了 -- (void)load_setImageImageWithUrl:(NSString *)url placeholderImage:(NSString *)placeholderImage success:(void (^)(UIImage *image))success{ - [self sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:placeholderImage ? [UIImage imageNamed:placeholderImage] : nil completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { - success(image); - }]; +- (void)load_imageWithUrl:(NSString *)url placeholderImage:(UIImage *)placeholderImage type:(ImageType)type success:(void (^)(UIImage *image))success{ + [self load_imageWithUrl:url placeholderImage:placeholderImage type:type cornerRadious:0 success:success]; } - (NSString *)URLEncodedString:(NSString *)string diff --git a/xplan-ios/Base/UI/VagueImageView/UIImage+ImageEffects.h b/xplan-ios/Base/UI/VagueImageView/UIImage+ImageEffects.h new file mode 100755 index 00000000..5e1b1085 --- /dev/null +++ b/xplan-ios/Base/UI/VagueImageView/UIImage+ImageEffects.h @@ -0,0 +1,107 @@ +/* + File: UIImage+ImageEffects.h + Abstract: This is a category of UIImage that adds methods to apply blur and tint effects to an image. This is the code you’ll want to look out to find out how to use vImage to efficiently calculate a blur. + Version: 1.0 + + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple + Inc. ("Apple") in consideration of your agreement to the following + terms, and your use, installation, modification or redistribution of + this Apple software constitutes acceptance of these terms. If you do + not agree with these terms, please do not use, install, modify or + redistribute this Apple software. + + In consideration of your agreement to abide by the following terms, and + subject to these terms, Apple grants you a personal, non-exclusive + license, under Apple's copyrights in this original Apple software (the + "Apple Software"), to use, reproduce, modify and redistribute the Apple + Software, with or without modifications, in source and/or binary forms; + provided that if you redistribute the Apple Software in its entirety and + without modifications, you must retain this notice and the following + text and disclaimers in all such redistributions of the Apple Software. + Neither the name, trademarks, service marks or logos of Apple Inc. may + be used to endorse or promote products derived from the Apple Software + without specific prior written permission from Apple. Except as + expressly stated in this notice, no other rights or licenses, express or + implied, are granted by Apple herein, including but not limited to any + patent rights that may be infringed by your derivative works or by other + works in which the Apple Software may be incorporated. + + The Apple Software is provided by Apple on an "AS IS" basis. APPLE + MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION + THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND + OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, + MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED + AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), + STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + + Copyright (C) 2013 Apple Inc. All Rights Reserved. + + + Copyright © 2013 Apple Inc. All rights reserved. + WWDC 2013 License + + NOTE: This Apple Software was supplied by Apple as part of a WWDC 2013 + Session. Please refer to the applicable WWDC 2013 Session for further + information. + + IMPORTANT: This Apple software is supplied to you by Apple Inc. + ("Apple") in consideration of your agreement to the following terms, and + your use, installation, modification or redistribution of this Apple + software constitutes acceptance of these terms. If you do not agree with + these terms, please do not use, install, modify or redistribute this + Apple software. + + In consideration of your agreement to abide by the following terms, and + subject to these terms, Apple grants you a non-exclusive license, under + Apple's copyrights in this original Apple software (the "Apple + Software"), to use, reproduce, modify and redistribute the Apple + Software, with or without modifications, in source and/or binary forms; + provided that if you redistribute the Apple Software in its entirety and + without modifications, you must retain this notice and the following + text and disclaimers in all such redistributions of the Apple Software. + Neither the name, trademarks, service marks or logos of Apple Inc. may + be used to endorse or promote products derived from the Apple Software + without specific prior written permission from Apple. Except as + expressly stated in this notice, no other rights or licenses, express or + implied, are granted by Apple herein, including but not limited to any + patent rights that may be infringed by your derivative works or by other + works in which the Apple Software may be incorporated. + + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES + NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE + IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND + OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, + MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED + AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), + STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + + EA1002 + 5/3/2013 + */ + +#import + +@interface UIImage (ImageEffects) + +- (UIImage *)applyLightEffect; +- (UIImage *)applyExtraLightEffect; +- (UIImage *)applyDarkEffect; +- (UIImage *)applyTintEffectWithColor:(UIColor *)tintColor; + +- (UIImage *)applyBlurWithRadius:(CGFloat)blurRadius tintColor:(UIColor *)tintColor saturationDeltaFactor:(CGFloat)saturationDeltaFactor maskImage:(UIImage *)maskImage; + +@end diff --git a/xplan-ios/Base/UI/VagueImageView/UIImage+ImageEffects.m b/xplan-ios/Base/UI/VagueImageView/UIImage+ImageEffects.m new file mode 100755 index 00000000..e1d6acd2 --- /dev/null +++ b/xplan-ios/Base/UI/VagueImageView/UIImage+ImageEffects.m @@ -0,0 +1,278 @@ +/* + File: UIImage+ImageEffects.m + Abstract: This is a category of UIImage that adds methods to apply blur and tint effects to an image. This is the code you’ll want to look out to find out how to use vImage to efficiently calculate a blur. + Version: 1.0 + + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple + Inc. ("Apple") in consideration of your agreement to the following + terms, and your use, installation, modification or redistribution of + this Apple software constitutes acceptance of these terms. If you do + not agree with these terms, please do not use, install, modify or + redistribute this Apple software. + + In consideration of your agreement to abide by the following terms, and + subject to these terms, Apple grants you a personal, non-exclusive + license, under Apple's copyrights in this original Apple software (the + "Apple Software"), to use, reproduce, modify and redistribute the Apple + Software, with or without modifications, in source and/or binary forms; + provided that if you redistribute the Apple Software in its entirety and + without modifications, you must retain this notice and the following + text and disclaimers in all such redistributions of the Apple Software. + Neither the name, trademarks, service marks or logos of Apple Inc. may + be used to endorse or promote products derived from the Apple Software + without specific prior written permission from Apple. Except as + expressly stated in this notice, no other rights or licenses, express or + implied, are granted by Apple herein, including but not limited to any + patent rights that may be infringed by your derivative works or by other + works in which the Apple Software may be incorporated. + + The Apple Software is provided by Apple on an "AS IS" basis. APPLE + MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION + THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND + OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, + MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED + AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), + STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + + Copyright (C) 2013 Apple Inc. All Rights Reserved. + + + Copyright © 2013 Apple Inc. All rights reserved. + WWDC 2013 License + + NOTE: This Apple Software was supplied by Apple as part of a WWDC 2013 + Session. Please refer to the applicable WWDC 2013 Session for further + information. + + IMPORTANT: This Apple software is supplied to you by Apple Inc. + ("Apple") in consideration of your agreement to the following terms, and + your use, installation, modification or redistribution of this Apple + software constitutes acceptance of these terms. If you do not agree with + these terms, please do not use, install, modify or redistribute this + Apple software. + + In consideration of your agreement to abide by the following terms, and + subject to these terms, Apple grants you a non-exclusive license, under + Apple's copyrights in this original Apple software (the "Apple + Software"), to use, reproduce, modify and redistribute the Apple + Software, with or without modifications, in source and/or binary forms; + provided that if you redistribute the Apple Software in its entirety and + without modifications, you must retain this notice and the following + text and disclaimers in all such redistributions of the Apple Software. + Neither the name, trademarks, service marks or logos of Apple Inc. may + be used to endorse or promote products derived from the Apple Software + without specific prior written permission from Apple. Except as + expressly stated in this notice, no other rights or licenses, express or + implied, are granted by Apple herein, including but not limited to any + patent rights that may be infringed by your derivative works or by other + works in which the Apple Software may be incorporated. + + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES + NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE + IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND + OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, + MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED + AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), + STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + + EA1002 + 5/3/2013 + */ + +#import "UIImage+ImageEffects.h" + +#import +#import + + +@implementation UIImage (ImageEffects) + + +- (UIImage *)applyLightEffect +{ + UIColor *tintColor = [UIColor colorWithWhite:1.0 alpha:0.3]; + return [self applyBlurWithRadius:30 tintColor:tintColor saturationDeltaFactor:1.8 maskImage:nil]; +} + + +- (UIImage *)applyExtraLightEffect +{ + UIColor *tintColor = [UIColor colorWithWhite:0.97 alpha:0.82]; + return [self applyBlurWithRadius:20 tintColor:tintColor saturationDeltaFactor:1.8 maskImage:nil]; +} + + +- (UIImage *)applyDarkEffect +{ + UIColor *tintColor = [UIColor colorWithWhite:0.11 alpha:0.73]; + return [self applyBlurWithRadius:20 tintColor:tintColor saturationDeltaFactor:1.8 maskImage:nil]; +} + + +- (UIImage *)applyTintEffectWithColor:(UIColor *)tintColor +{ + const CGFloat EffectColorAlpha = 0.6; + UIColor *effectColor = tintColor; + int componentCount = CGColorGetNumberOfComponents(tintColor.CGColor); + if (componentCount == 2) { + CGFloat b; + if ([tintColor getWhite:&b alpha:NULL]) { + effectColor = [UIColor colorWithWhite:b alpha:EffectColorAlpha]; + } + } + else { + CGFloat r, g, b; + if ([tintColor getRed:&r green:&g blue:&b alpha:NULL]) { + effectColor = [UIColor colorWithRed:r green:g blue:b alpha:EffectColorAlpha]; + } + } + return [self applyBlurWithRadius:10 tintColor:effectColor saturationDeltaFactor:-1.0 maskImage:nil]; +} + + +- (UIImage *)applyBlurWithRadius:(CGFloat)blurRadius tintColor:(UIColor *)tintColor saturationDeltaFactor:(CGFloat)saturationDeltaFactor maskImage:(UIImage *)maskImage +{ + // Check pre-conditions. + if (self.size.width < 1 || self.size.height < 1) { + NSLog (@"*** error: invalid size: (%.2f x %.2f). Both dimensions must be >= 1: %@", self.size.width, self.size.height, self); + return nil; + } + if (!self.CGImage) { + NSLog (@"*** error: image must be backed by a CGImage: %@", self); + return nil; + } + if (maskImage && !maskImage.CGImage) { + NSLog (@"*** error: maskImage must be backed by a CGImage: %@", maskImage); + return nil; + } + + CGRect imageRect = { CGPointZero, self.size }; + UIImage *effectImage = self; + + BOOL hasBlur = blurRadius > __FLT_EPSILON__; + BOOL hasSaturationChange = fabs(saturationDeltaFactor - 1.) > __FLT_EPSILON__; + if (hasBlur || hasSaturationChange) { + UIGraphicsBeginImageContextWithOptions(self.size, NO, [[UIScreen mainScreen] scale]); + CGContextRef effectInContext = UIGraphicsGetCurrentContext(); + CGContextScaleCTM(effectInContext, 1.0, -1.0); + CGContextTranslateCTM(effectInContext, 0, -self.size.height); + CGContextDrawImage(effectInContext, imageRect, self.CGImage); + + vImage_Buffer effectInBuffer; + effectInBuffer.data = CGBitmapContextGetData(effectInContext); + effectInBuffer.width = CGBitmapContextGetWidth(effectInContext); + effectInBuffer.height = CGBitmapContextGetHeight(effectInContext); + effectInBuffer.rowBytes = CGBitmapContextGetBytesPerRow(effectInContext); + + UIGraphicsBeginImageContextWithOptions(self.size, NO, [[UIScreen mainScreen] scale]); + CGContextRef effectOutContext = UIGraphicsGetCurrentContext(); + vImage_Buffer effectOutBuffer; + effectOutBuffer.data = CGBitmapContextGetData(effectOutContext); + effectOutBuffer.width = CGBitmapContextGetWidth(effectOutContext); + effectOutBuffer.height = CGBitmapContextGetHeight(effectOutContext); + effectOutBuffer.rowBytes = CGBitmapContextGetBytesPerRow(effectOutContext); + + if (hasBlur) { + // A description of how to compute the box kernel width from the Gaussian + // radius (aka standard deviation) appears in the SVG spec: + // http://www.w3.org/TR/SVG/filters.html#feGaussianBlurElement + // + // For larger values of 's' (s >= 2.0), an approximation can be used: Three + // successive box-blurs build a piece-wise quadratic convolution kernel, which + // approximates the Gaussian kernel to within roughly 3%. + // + // let d = floor(s * 3*sqrt(2*pi)/4 + 0.5) + // + // ... if d is odd, use three box-blurs of size 'd', centered on the output pixel. + // + CGFloat inputRadius = blurRadius * [[UIScreen mainScreen] scale]; + NSUInteger radius = floor(inputRadius * 3. * sqrt(2 * M_PI) / 4 + 0.5); + if (radius % 2 != 1) { + radius += 1; // force radius to be odd so that the three box-blur methodology works. + } + vImageBoxConvolve_ARGB8888(&effectInBuffer, &effectOutBuffer, NULL, 0, 0, radius, radius, 0, kvImageEdgeExtend); + vImageBoxConvolve_ARGB8888(&effectOutBuffer, &effectInBuffer, NULL, 0, 0, radius, radius, 0, kvImageEdgeExtend); + vImageBoxConvolve_ARGB8888(&effectInBuffer, &effectOutBuffer, NULL, 0, 0, radius, radius, 0, kvImageEdgeExtend); + } + BOOL effectImageBuffersAreSwapped = NO; + if (hasSaturationChange) { + CGFloat s = saturationDeltaFactor; + CGFloat floatingPointSaturationMatrix[] = { + 0.0722 + 0.9278 * s, 0.0722 - 0.0722 * s, 0.0722 - 0.0722 * s, 0, + 0.7152 - 0.7152 * s, 0.7152 + 0.2848 * s, 0.7152 - 0.7152 * s, 0, + 0.2126 - 0.2126 * s, 0.2126 - 0.2126 * s, 0.2126 + 0.7873 * s, 0, + 0, 0, 0, 1, + }; + const int32_t divisor = 256; + NSUInteger matrixSize = sizeof(floatingPointSaturationMatrix)/sizeof(floatingPointSaturationMatrix[0]); + int16_t saturationMatrix[matrixSize]; + for (NSUInteger i = 0; i < matrixSize; ++i) { + saturationMatrix[i] = (int16_t)roundf(floatingPointSaturationMatrix[i] * divisor); + } + if (hasBlur) { + vImageMatrixMultiply_ARGB8888(&effectOutBuffer, &effectInBuffer, saturationMatrix, divisor, NULL, NULL, kvImageNoFlags); + effectImageBuffersAreSwapped = YES; + } + else { + vImageMatrixMultiply_ARGB8888(&effectInBuffer, &effectOutBuffer, saturationMatrix, divisor, NULL, NULL, kvImageNoFlags); + } + } + if (!effectImageBuffersAreSwapped) + effectImage = UIGraphicsGetImageFromCurrentImageContext(); + UIGraphicsEndImageContext(); + + if (effectImageBuffersAreSwapped) + effectImage = UIGraphicsGetImageFromCurrentImageContext(); + UIGraphicsEndImageContext(); + } + + // Set up output context. + UIGraphicsBeginImageContextWithOptions(self.size, NO, [[UIScreen mainScreen] scale]); + CGContextRef outputContext = UIGraphicsGetCurrentContext(); + CGContextScaleCTM(outputContext, 1.0, -1.0); + CGContextTranslateCTM(outputContext, 0, -self.size.height); + + // Draw base image. + CGContextDrawImage(outputContext, imageRect, self.CGImage); + + // Draw effect image. + if (hasBlur) { + CGContextSaveGState(outputContext); + if (maskImage) { + CGContextClipToMask(outputContext, imageRect, maskImage.CGImage); + } + CGContextDrawImage(outputContext, imageRect, effectImage.CGImage); + CGContextRestoreGState(outputContext); + } + + // Add in color tint. + if (tintColor) { + CGContextSaveGState(outputContext); + CGContextSetFillColorWithColor(outputContext, tintColor.CGColor); + CGContextFillRect(outputContext, imageRect); + CGContextRestoreGState(outputContext); + } + + // Output image is ready. + UIImage *outputImage = UIGraphicsGetImageFromCurrentImageContext(); + UIGraphicsEndImageContext(); + + return outputImage; +} + + +@end diff --git a/xplan-ios/Base/UI/VagueImageView/UIImageView+Vague.h b/xplan-ios/Base/UI/VagueImageView/UIImageView+Vague.h new file mode 100644 index 00000000..b9b5e2f4 --- /dev/null +++ b/xplan-ios/Base/UI/VagueImageView/UIImageView+Vague.h @@ -0,0 +1,20 @@ +// +// UIImageView+Vague.h +// xplan-ios +// +// Created by 冯硕 on 2021/9/27. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface UIImageView (Vague) +/// 模糊的效果 +/// @param image 需要模糊的图片 +/// @param blurRadius 角度 越大 模糊的越不明显 默认20 +- (void)setImageToBlur:(UIImage *)image + blurRadius:(CGFloat)blurRadius; +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Base/UI/VagueImageView/UIImageView+Vague.m b/xplan-ios/Base/UI/VagueImageView/UIImageView+Vague.m new file mode 100644 index 00000000..9e0ad446 --- /dev/null +++ b/xplan-ios/Base/UI/VagueImageView/UIImageView+Vague.m @@ -0,0 +1,34 @@ +// +// UIImageView+Vague.m +// xplan-ios +// +// Created by 冯硕 on 2021/9/27. +// + +#import "UIImageView+Vague.h" +#import "UIImage+ImageEffects.h" +@implementation UIImageView (Vague) + +/// 模糊的效果 +/// @param image 需要模糊的图片 +/// @param blurRadius 角度 越大 模糊的越明显 默认20 +- (void)setImageToBlur:(UIImage *)image + blurRadius:(CGFloat)blurRadius { + NSParameterAssert(image); + if (blurRadius < 0) { + blurRadius = 20; + } + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + + UIImage *blurredImage = [image applyBlurWithRadius:blurRadius + tintColor:nil + saturationDeltaFactor:1.8 + maskImage:nil]; + + dispatch_async(dispatch_get_main_queue(), ^{ + self.image = blurredImage; + }); + }); +} + +@end diff --git a/xplan-ios/Main/Mine/View/Cell/MineInfo/XPMineUserInfoAlbumCollectionViewCell.m b/xplan-ios/Main/Mine/View/Cell/MineInfo/XPMineUserInfoAlbumCollectionViewCell.m index 2dd661ad..f5c435e2 100644 --- a/xplan-ios/Main/Mine/View/Cell/MineInfo/XPMineUserInfoAlbumCollectionViewCell.m +++ b/xplan-ios/Main/Mine/View/Cell/MineInfo/XPMineUserInfoAlbumCollectionViewCell.m @@ -58,7 +58,7 @@ - (void)setPhoto:(UserPhoto *)photo { _photo = photo; if (_photo) { - [self.logoImageView load_setImageImageWithUrl:_photo.photoUrl placeholderImage:[UIImageConstant defaultAvatarPlaceholder] type:ImageTypeUserLibaryDetail]; + [self.logoImageView load_imageWithUrl:_photo.photoUrl placeholderImage:[UIImageConstant defaultAvatarPlaceholder] type:ImageTypeUserLibaryDetail]; } } diff --git a/xplan-ios/Main/Mine/View/Cell/MineInfo/XPMineUserInfoEditTableViewCell.m b/xplan-ios/Main/Mine/View/Cell/MineInfo/XPMineUserInfoEditTableViewCell.m index 0df82df4..226d140c 100644 --- a/xplan-ios/Main/Mine/View/Cell/MineInfo/XPMineUserInfoEditTableViewCell.m +++ b/xplan-ios/Main/Mine/View/Cell/MineInfo/XPMineUserInfoEditTableViewCell.m @@ -113,7 +113,7 @@ for (int i = 0; i < array.count; i++) { UIImageView * imageView = [self.photoViewArray objectAtIndex:i]; NSString * imageUrl = [array objectAtIndex:i].photoUrl; - [imageView load_setImageImageWithUrl:imageUrl placeholderImage:[UIImageConstant defaultAvatarPlaceholder] type:ImageTypeUserIcon]; + [imageView load_imageWithUrl:imageUrl placeholderImage:[UIImageConstant defaultAvatarPlaceholder] type:ImageTypeUserIcon]; } } @@ -125,7 +125,7 @@ self.phototStackView.hidden = YES; self.avatarImageView.hidden = NO; if (model.avatarUrl.length > 0) { - [self.avatarImageView load_setImageImageWithUrl:model.avatarUrl placeholderImage:[UIImageConstant defaultAvatarPlaceholder] type:ImageTypeUserIcon]; + [self.avatarImageView load_imageWithUrl:model.avatarUrl placeholderImage:[UIImageConstant defaultAvatarPlaceholder] type:ImageTypeUserIcon]; } } break; diff --git a/xplan-ios/Main/Mine/View/MineInfo/XPMineUserInfoAlbumViewController.m b/xplan-ios/Main/Mine/View/MineInfo/XPMineUserInfoAlbumViewController.m index 64463f43..ae237ab5 100644 --- a/xplan-ios/Main/Mine/View/MineInfo/XPMineUserInfoAlbumViewController.m +++ b/xplan-ios/Main/Mine/View/MineInfo/XPMineUserInfoAlbumViewController.m @@ -194,7 +194,7 @@ #pragma mark - SDPhotoBrowserDelegate - (UIImage *)photoBrowser:(SDPhotoBrowser *)browser placeholderImageForIndex:(NSInteger)index { - return [UIImage imageNamed:[UIImageConstant defaultAvatarPlaceholder]]; + return [UIImageConstant defaultAvatarPlaceholder]; } - (NSURL *)photoBrowser:(SDPhotoBrowser *)browser highQualityImageURLForIndex:(NSInteger)index { diff --git a/xplan-ios/Main/Mine/View/MineInfo/XPMineUserInfoViewController.h b/xplan-ios/Main/Mine/View/MineInfo/XPMineUserInfoViewController.h index 348c599b..55c02e70 100644 --- a/xplan-ios/Main/Mine/View/MineInfo/XPMineUserInfoViewController.h +++ b/xplan-ios/Main/Mine/View/MineInfo/XPMineUserInfoViewController.h @@ -11,7 +11,9 @@ NS_ASSUME_NONNULL_BEGIN @interface XPMineUserInfoViewController : MvpViewController ///用户的id -@property (nonatomic,assign) long long uid; +@property (nonatomic,assign) NSInteger uid; + +- (UIView *)getHeadHitView; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Mine/View/MineInfo/XPMineUserInfoViewController.m b/xplan-ios/Main/Mine/View/MineInfo/XPMineUserInfoViewController.m index 30ff2be4..e9c2b158 100644 --- a/xplan-ios/Main/Mine/View/MineInfo/XPMineUserInfoViewController.m +++ b/xplan-ios/Main/Mine/View/MineInfo/XPMineUserInfoViewController.m @@ -8,6 +8,7 @@ #import "XPMineUserInfoViewController.h" ///Third #import +#import ///Tool #import "ThemeColor.h" #import "XPMacro.h" @@ -15,6 +16,7 @@ #import "XPMineUserInfoTableViewCell.h" #import "XPMineUserInfoHeaderView.h" #import "XPMineUserInfoCustomNavView.h" +#import "XPMineUserTableView.h" ///P #import "XPMineUserInfoPresenter.h" #import "XPMineUserInfoProtocol.h" @@ -23,7 +25,7 @@ @interface XPMineUserInfoViewController () ///列别 -@property (nonatomic,strong) UITableView *tableView; +@property (nonatomic,strong) XPMineUserTableView *tableView; ///头部视图 @property (nonatomic,strong) XPMineUserInfoHeaderView *headView; ///table的顶部视图 @@ -58,6 +60,11 @@ } } +#pragma mark - Public Method +- (UIView *)getHeadHitView { + return self.headView.cycleScrollView; +} + #pragma mark - Private Method - (void)initSubViews { [self.view addSubview:self.headView]; @@ -65,6 +72,7 @@ [self.view addSubview:self.navView]; #warning to do 头像无法点击的问题 self.tableView.tableHeaderView = self.tableViewHeadView; + self.tableView.userInfoVC = self; } - (void)initSubViewConstraints { @@ -123,17 +131,17 @@ } #pragma mark - Getters And Setters -- (void)setUid:(long long)uid { +- (void)setUid:(NSInteger)uid { _uid = uid; if (_uid > 0) { - NSString * uidStr = [NSString stringWithFormat:@"%lld", uid]; + NSString * uidStr = [NSString stringWithFormat:@"%d", uid]; [self.presenter getUserInfoWithUid:uidStr]; } } -- (UITableView *)tableView { +- (XPMineUserTableView *)tableView { if (!_tableView) { - _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped]; + _tableView = [[XPMineUserTableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped]; _tableView.delegate = self; _tableView.dataSource = self; _tableView.tableFooterView = [UIView new]; diff --git a/xplan-ios/Main/Mine/View/Cell/MineInfo/XPMineUserInfoCustomNavView.h b/xplan-ios/Main/Mine/View/SubViews/MineInfo/XPMineUserInfoCustomNavView.h similarity index 100% rename from xplan-ios/Main/Mine/View/Cell/MineInfo/XPMineUserInfoCustomNavView.h rename to xplan-ios/Main/Mine/View/SubViews/MineInfo/XPMineUserInfoCustomNavView.h diff --git a/xplan-ios/Main/Mine/View/Cell/MineInfo/XPMineUserInfoCustomNavView.m b/xplan-ios/Main/Mine/View/SubViews/MineInfo/XPMineUserInfoCustomNavView.m similarity index 100% rename from xplan-ios/Main/Mine/View/Cell/MineInfo/XPMineUserInfoCustomNavView.m rename to xplan-ios/Main/Mine/View/SubViews/MineInfo/XPMineUserInfoCustomNavView.m diff --git a/xplan-ios/Main/Mine/View/SubViews/MineInfo/XPMineUserInfoHeaderView.h b/xplan-ios/Main/Mine/View/SubViews/MineInfo/XPMineUserInfoHeaderView.h index ea00ad7a..562b2f28 100644 --- a/xplan-ios/Main/Mine/View/SubViews/MineInfo/XPMineUserInfoHeaderView.h +++ b/xplan-ios/Main/Mine/View/SubViews/MineInfo/XPMineUserInfoHeaderView.h @@ -8,10 +8,12 @@ #import NS_ASSUME_NONNULL_BEGIN -@class UserInfoModel; +@class UserInfoModel, SDCycleScrollView; @interface XPMineUserInfoHeaderView : UIView /// @property (nonatomic,strong) UserInfoModel *userInfo; +///轮播图 +@property (nonatomic,strong, readonly) SDCycleScrollView *cycleScrollView; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Mine/View/SubViews/MineInfo/XPMineUserInfoHeaderView.m b/xplan-ios/Main/Mine/View/SubViews/MineInfo/XPMineUserInfoHeaderView.m index f59702c9..a49010ae 100644 --- a/xplan-ios/Main/Mine/View/SubViews/MineInfo/XPMineUserInfoHeaderView.m +++ b/xplan-ios/Main/Mine/View/SubViews/MineInfo/XPMineUserInfoHeaderView.m @@ -14,17 +14,58 @@ ///Tool #import "ThemeColor.h" #import "XPMacro.h" -#import "UIImageConstant.h" +#import "UIImageView+LoadImage.h" +#import "UIImageView+Vague.h" ///Model #import "UserInfoModel.h" +@interface XPMineUserInfoImageCollectionViewCell : UICollectionViewCell +/// +@property (nonatomic,strong) UIImageView *logoImageView; +@end + +@implementation XPMineUserInfoImageCollectionViewCell + +- (instancetype)initWithFrame:(CGRect)frame +{ + self = [super initWithFrame:frame]; + if (self) { + [self initSubViews]; + [self initSubViewConstraints]; + } + return self; +} + +#pragma mark - Private Method +- (void)initSubViews { + [self.contentView addSubview:self.logoImageView]; +} + +- (void)initSubViewConstraints { + [self.logoImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.mas_equalTo(self.contentView); + }]; +} + +#pragma mark - Getters And Setters +- (UIImageView *)logoImageView { + if (!_logoImageView) { + _logoImageView = [[UIImageView alloc] init]; + _logoImageView.userInteractionEnabled = YES; + _logoImageView.layer.masksToBounds = YES; + _logoImageView.contentMode = UIViewContentModeScaleAspectFill; + } + return _logoImageView; +} + +@end + + @interface XPMineUserInfoHeaderView () ///覆盖的 @property (nonatomic,strong) UIView * coverView; ///轮播图 @property (nonatomic,strong) SDCycleScrollView *cycleScrollView; -///高斯模糊 -@property (nonatomic,strong) UIVisualEffectView *effectView; ///显示当前的页数 @property (nonatomic,strong) UILabel *pageLabel; ///图片数组 @@ -44,7 +85,6 @@ #pragma mark - Private Method - (void)initSubViews { [self addSubview:self.cycleScrollView]; - [self addSubview:self.effectView]; [self addSubview:self.coverView]; [self addSubview:self.pageLabel]; } @@ -54,10 +94,6 @@ make.edges.mas_equalTo(self); }]; - [self.effectView mas_makeConstraints:^(MASConstraintMaker *make) { - make.edges.mas_equalTo(self); - }]; - [self.coverView mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.mas_equalTo(self.cycleScrollView); }]; @@ -76,12 +112,29 @@ } - (UIImage *)photoBrowser:(SDPhotoBrowser *)browser placeholderImageForIndex:(NSInteger)index { - return [UIImage imageNamed:[UIImageConstant defalutBannerPlaceholder]]; + return [UIImageConstant defalutBannerPlaceholder]; } #pragma mark - SDCycleScrollViewDelegate +/** 如果你需要自定义cell样式,请在实现此代理方法返回你的自定义cell的class。 */ +- (Class)customCollectionViewCellClassForCycleScrollView:(SDCycleScrollView *)view { + return [XPMineUserInfoImageCollectionViewCell class]; +} + +- (void)setupCustomCell:(UICollectionViewCell *)cell forIndex:(NSInteger)index cycleScrollView:(SDCycleScrollView *)view { + XPMineUserInfoImageCollectionViewCell * imageCell = (XPMineUserInfoImageCollectionViewCell *)cell; + NSString *url = [self.imageUrls objectAtIndex:index]; + @weakify(imageCell); + [imageCell.logoImageView load_imageWithUrl:url placeholderImage:[UIImageConstant defalutBannerPlaceholder] type:ImageTypeUserInfoAlbum success:^(UIImage * _Nonnull image) { + @strongify(imageCell); + if (image) { + [imageCell.logoImageView setImageToBlur:image blurRadius:45]; + } + }]; +} + -(void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didScrollToIndex:(NSInteger)index { - self.pageLabel.text = [NSString stringWithFormat:@"%ld/%lu",(index + 1), (unsigned long)self.imageUrls.count]; + self.pageLabel.text = [NSString stringWithFormat:@"%d/%lu",(index + 1), (unsigned long)self.imageUrls.count]; } // 轮播图点击 @@ -124,7 +177,7 @@ if (!_coverView) { _coverView = [[UIView alloc] init]; _coverView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:1]; - _coverView.alpha = 0.5; + _coverView.alpha = 0.2; } return _coverView; } @@ -136,21 +189,12 @@ _cycleScrollView.delegate = self; _cycleScrollView.bannerImageViewContentMode = UIViewContentModeScaleAspectFill; _cycleScrollView.pageControlStyle = SDCycleScrollViewPageContolStyleNone;; - _cycleScrollView.placeholderImage = [UIImage imageNamed:[UIImageConstant defaultAvatarPlaceholder]]; + _cycleScrollView.placeholderImage = [UIImageConstant defaultAvatarPlaceholder]; _cycleScrollView.autoScroll = NO; } return _cycleScrollView; } -- (UIVisualEffectView *)effectView { - if (!_effectView) { - UIBlurEffect *beffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]; - UIVisualEffectView *view = [[UIVisualEffectView alloc]initWithEffect:beffect]; - _effectView = view; - } - return _effectView; -} - - (UILabel *)pageLabel { if (!_pageLabel) { _pageLabel = [[UILabel alloc] init]; diff --git a/xplan-ios/Main/Mine/View/SubViews/MineInfo/XPMineUserTableView.h b/xplan-ios/Main/Mine/View/SubViews/MineInfo/XPMineUserTableView.h new file mode 100644 index 00000000..ed213766 --- /dev/null +++ b/xplan-ios/Main/Mine/View/SubViews/MineInfo/XPMineUserTableView.h @@ -0,0 +1,16 @@ +// +// XPMineUserTableView.h +// xplan-ios +// +// Created by 冯硕 on 2021/9/27. +// + +#import + +NS_ASSUME_NONNULL_BEGIN +@interface XPMineUserTableView : UITableView +/// +@property (nonatomic,weak) UIViewController *userInfoVC; +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Mine/View/SubViews/MineInfo/XPMineUserTableView.m b/xplan-ios/Main/Mine/View/SubViews/MineInfo/XPMineUserTableView.m new file mode 100644 index 00000000..6ae4b871 --- /dev/null +++ b/xplan-ios/Main/Mine/View/SubViews/MineInfo/XPMineUserTableView.m @@ -0,0 +1,22 @@ +// +// XPMineUserTableView.m +// xplan-ios +// +// Created by 冯硕 on 2021/9/27. +// + +#import "XPMineUserTableView.h" +#import "XPMacro.h" +#import "XPMineUserInfoViewController.h" + +@implementation XPMineUserTableView + +- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { + if (point.y > (250 + kSafeAreaTopHeight)) { + return self; + } else { + return [[(XPMineUserInfoViewController *)self.userInfoVC getHeadHitView] hitTest:point withEvent:event]; + } +} + +@end diff --git a/xplan-ios/Main/Mine/View/SubViews/XPMineHeadView.m b/xplan-ios/Main/Mine/View/SubViews/XPMineHeadView.m index ddde4bec..5f72c0c7 100644 --- a/xplan-ios/Main/Mine/View/SubViews/XPMineHeadView.m +++ b/xplan-ios/Main/Mine/View/SubViews/XPMineHeadView.m @@ -129,7 +129,7 @@ if (_userInfo) { self.idLabel.text = [NSString stringWithFormat:@"音游号:%ld", (long)_userInfo.erbanNo]; self.nameLabel.text = _userInfo.nick.length > 0 ? _userInfo.nick : @""; - [self.avatarImageView load_setImageImageWithUrl:_userInfo.avatar placeholderImage:[UIImageConstant defaultAvatarPlaceholder]]; + [self.avatarImageView load_imageWithUrl:_userInfo.avatar placeholderImage:[UIImageConstant defaultAvatarPlaceholder] type:ImageTypeUserIcon]; NSString * sexName; if (userInfo.gender == GenderType_Male) { sexName = @"common_male";