From d99d5a874859d7894b7094ea63a468f500636885 Mon Sep 17 00:00:00 2001 From: fengshuo <963787902@qq.com> Date: Fri, 21 Oct 2022 20:38:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E8=BF=9B=E5=BA=A6?= =?UTF-8?q?=E6=9D=A1=E6=98=BE=E7=A4=BA=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xplan-ios.xcodeproj/project.pbxproj | 6 --- .../Room/View/WishGift/View/View/XPSlider.h | 18 -------- .../Room/View/WishGift/View/View/XPSlider.m | 16 ------- .../WishGift/View/View/XPWishGiftEnterView.h | 2 + .../WishGift/View/View/XPWishGiftEnterView.m | 42 +++++++++++-------- .../WishGift/View/View/XPWishGiftInfoView.m | 42 +++++++++++++------ 6 files changed, 55 insertions(+), 71 deletions(-) delete mode 100644 xplan-ios/Main/Room/View/WishGift/View/View/XPSlider.h delete mode 100644 xplan-ios/Main/Room/View/WishGift/View/View/XPSlider.m diff --git a/xplan-ios.xcodeproj/project.pbxproj b/xplan-ios.xcodeproj/project.pbxproj index 93683cb1..28ab25f8 100644 --- a/xplan-ios.xcodeproj/project.pbxproj +++ b/xplan-ios.xcodeproj/project.pbxproj @@ -669,7 +669,6 @@ E8395339276A0CC100CF2F24 /* XPMineHeadwearTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E8395338276A0CC100CF2F24 /* XPMineHeadwearTableViewCell.m */; }; E839533C276A0CCD00CF2F24 /* XPMineCarTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E839533B276A0CCD00CF2F24 /* XPMineCarTableViewCell.m */; }; E839533F276A0CDB00CF2F24 /* XPMineNameplateTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E839533E276A0CDB00CF2F24 /* XPMineNameplateTableViewCell.m */; }; - E83980662902728D0084BFC8 /* XPSlider.m in Sources */ = {isa = PBXBuildFile; fileRef = E83980652902728D0084BFC8 /* XPSlider.m */; }; E839806829027D4A0084BFC8 /* room_wish_gift_sendCelebrate.svga in Resources */ = {isa = PBXBuildFile; fileRef = E839806729027D4A0084BFC8 /* room_wish_gift_sendCelebrate.svga */; }; E839806B290288660084BFC8 /* XPMessageInfoModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E839806A290288660084BFC8 /* XPMessageInfoModel.m */; }; E83ABEF6280E9AD800322EE4 /* MessageContentUnSupportView.m in Sources */ = {isa = PBXBuildFile; fileRef = E83ABEF5280E9AD800322EE4 /* MessageContentUnSupportView.m */; }; @@ -2383,8 +2382,6 @@ E839533B276A0CCD00CF2F24 /* XPMineCarTableViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMineCarTableViewCell.m; sourceTree = ""; }; E839533D276A0CDB00CF2F24 /* XPMineNameplateTableViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineNameplateTableViewCell.h; sourceTree = ""; }; E839533E276A0CDB00CF2F24 /* XPMineNameplateTableViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMineNameplateTableViewCell.m; sourceTree = ""; }; - E83980642902728D0084BFC8 /* XPSlider.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPSlider.h; sourceTree = ""; }; - E83980652902728D0084BFC8 /* XPSlider.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPSlider.m; sourceTree = ""; }; E839806729027D4A0084BFC8 /* room_wish_gift_sendCelebrate.svga */ = {isa = PBXFileReference; lastKnownFileType = file; path = room_wish_gift_sendCelebrate.svga; sourceTree = ""; }; E8398069290288660084BFC8 /* XPMessageInfoModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMessageInfoModel.h; sourceTree = ""; }; E839806A290288660084BFC8 /* XPMessageInfoModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMessageInfoModel.m; sourceTree = ""; }; @@ -7395,8 +7392,6 @@ E89DCF5928FFF1AD001647EC /* XPWishGiftSectionView.m */, E89DCF5E2900F4FB001647EC /* XPWishGiftEnterView.h */, E89DCF5F2900F4FB001647EC /* XPWishGiftEnterView.m */, - E83980642902728D0084BFC8 /* XPSlider.h */, - E83980652902728D0084BFC8 /* XPSlider.m */, ); path = View; sourceTree = ""; @@ -9538,7 +9533,6 @@ E82325F2274E2DE6003A3332 /* XPUserCardViewController.m in Sources */, E8E859D228264C2300EE4857 /* HTTPServer.m in Sources */, E8F65C222869A36F009BB5B9 /* ContentShareMonentsModel.m in Sources */, - E83980662902728D0084BFC8 /* XPSlider.m in Sources */, E8C167182806A03800ECB15C /* XPSuperAdminSetPresenter.m in Sources */, 9B6E856E281AABAB0041A321 /* XPRoomRecommendModel.m in Sources */, E801274B27E327DA00BAC3F2 /* XPRoomPKTypeTableViewCell.m in Sources */, diff --git a/xplan-ios/Main/Room/View/WishGift/View/View/XPSlider.h b/xplan-ios/Main/Room/View/WishGift/View/View/XPSlider.h deleted file mode 100644 index fc6a121c..00000000 --- a/xplan-ios/Main/Room/View/WishGift/View/View/XPSlider.h +++ /dev/null @@ -1,18 +0,0 @@ -// -// XPSlider.h -// xplan-ios -// -// Created by 冯硕 on 2022/10/21. -// - -#import - -NS_ASSUME_NONNULL_BEGIN - -@interface XPSlider : UISlider -/// -@property (nonatomic,assign) CGFloat height; - -@end - -NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Room/View/WishGift/View/View/XPSlider.m b/xplan-ios/Main/Room/View/WishGift/View/View/XPSlider.m deleted file mode 100644 index 8498feba..00000000 --- a/xplan-ios/Main/Room/View/WishGift/View/View/XPSlider.m +++ /dev/null @@ -1,16 +0,0 @@ -// -// XPSlider.m -// xplan-ios -// -// Created by 冯硕 on 2022/10/21. -// - -#import "XPSlider.h" - -@implementation XPSlider - -- (CGRect)trackRectForBounds:(CGRect)bounds { - return CGRectMake(bounds.origin.x, bounds.origin.y, bounds.size.width, self.height); -} - -@end diff --git a/xplan-ios/Main/Room/View/WishGift/View/View/XPWishGiftEnterView.h b/xplan-ios/Main/Room/View/WishGift/View/View/XPWishGiftEnterView.h index fc9340f8..45e394e9 100644 --- a/xplan-ios/Main/Room/View/WishGift/View/View/XPWishGiftEnterView.h +++ b/xplan-ios/Main/Room/View/WishGift/View/View/XPWishGiftEnterView.h @@ -10,6 +10,8 @@ NS_ASSUME_NONNULL_BEGIN @interface XPWishGiftEnterView : UIView @property (nonatomic,strong) NSArray * giftList; +///是否在左边 +@property (nonatomic,assign) BOOL isLeft; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Room/View/WishGift/View/View/XPWishGiftEnterView.m b/xplan-ios/Main/Room/View/WishGift/View/View/XPWishGiftEnterView.m index fe1bb0f5..96068781 100644 --- a/xplan-ios/Main/Room/View/WishGift/View/View/XPWishGiftEnterView.m +++ b/xplan-ios/Main/Room/View/WishGift/View/View/XPWishGiftEnterView.m @@ -15,11 +15,9 @@ #import "NetImageView.h" #import "UIImage+Utils.h" #import "UIView+Corner.h" -#import "XPSlider.h" ///Model #import "WishGiftInfoModel.h" - @interface XPWishGiftEnterCell : UICollectionViewCell ///礼物 @property (nonatomic,strong) NetImageView *giftImageView; @@ -28,7 +26,7 @@ ///进度 @property (nonatomic,strong) UILabel *progressLabel; ///进度 -@property (nonatomic,strong) XPSlider *progressView; +@property (nonatomic,strong) UIProgressView *progressView; @property (nonatomic,strong) WishGiftInfoModel *giftInfo; @end @@ -72,7 +70,7 @@ }]; [self.progressView mas_makeConstraints:^(MASConstraintMaker *make) { - make.height.mas_equalTo(5); + make.height.mas_equalTo(3); make.bottom.mas_equalTo(self.contentView.mas_bottom).offset(-2); make.left.mas_equalTo(self.giftImageView.mas_right).offset(2); make.right.mas_equalTo(self.contentView).offset(-5); @@ -102,25 +100,19 @@ if (value > 1){ value = 1; } - self.progressView.value = value; + [self.progressView setProgress:value animated:NO]; self.progressLabel.attributedText = [self createProgressAttribute]; self.progressLabel.textAlignment = NSTextAlignmentCenter; } } -- (XPSlider *)progressView { +- (UIProgressView *)progressView { if(!_progressView) { - _progressView = [[XPSlider alloc] init]; - _progressView.enabled = NO; - [_progressView setMinimumTrackImage:[UIImage gradientColorImageFromColors:@[[ThemeColor colorWithHexString:@"#FFA0C3"], [ThemeColor colorWithHexString:@"#C176FF"]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(1, 1)] forState:UIControlStateNormal]; - _progressView.thumbTintColor = [UIColor clearColor]; - _progressView.minimumValue = 0; - _progressView.maximumValue = 1; - _progressView.value = 0.01; - _progressView.height = 5; + _progressView = [[UIProgressView alloc] init]; _progressView.layer.masksToBounds = YES; - _progressView.layer.cornerRadius = 2.5; - [_progressView setMaximumTrackImage:[UIImage imageWithColor:[ThemeColor colorWithHexString:@"#17093E"]] forState:UIControlStateNormal]; + _progressView.layer.cornerRadius = 1.5; + _progressView.trackImage = [UIImage imageWithColor:[ThemeColor colorWithHexString:@"#17093E"]]; + _progressView.progressImage = [UIImage gradientColorImageFromColors:@[[ThemeColor colorWithHexString:@"#FFA0C3"], [ThemeColor colorWithHexString:@"#C176FF"]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(1, 1)]; } return _progressView; } @@ -173,6 +165,7 @@ if (self) { [self initSubViews]; [self initSubViewConstraints]; + self.isLeft = NO; } return self; } @@ -183,8 +176,6 @@ self.backgroundColor = [UIColor colorWithWhite:1 alpha:0.2]; [self addSubview:self.cycleScrollView]; self.layer.masksToBounds = YES; - - [self setCornerWithLeftTopCorner:15 rightTopCorner:0 bottomLeftCorner:15 bottomRightCorner:0 size:CGSizeMake(81, 30)]; } - (void)initSubViewConstraints { @@ -205,6 +196,21 @@ myCell.giftInfo = info; } #pragma mark - Getters And Setters +- (void)setIsLeft:(BOOL)isLeft { + _isLeft = isLeft; + for (CALayer * layer in self.layer.sublayers) { + if ([layer isKindOfClass:[CAShapeLayer class]]) { + [layer removeFromSuperlayer]; + } + } + + if (_isLeft) { + [self setCornerWithLeftTopCorner:0 rightTopCorner:15 bottomLeftCorner:0 bottomRightCorner:15 size:CGSizeMake(81, 30)]; + } else { + [self setCornerWithLeftTopCorner:15 rightTopCorner:0 bottomLeftCorner:15 bottomRightCorner:0 size:CGSizeMake(81, 30)]; + } +} + - (void)setGiftList:(NSArray *)giftList { _giftList = giftList; if (_giftList.count > 0) { diff --git a/xplan-ios/Main/Room/View/WishGift/View/View/XPWishGiftInfoView.m b/xplan-ios/Main/Room/View/WishGift/View/View/XPWishGiftInfoView.m index 52d9c898..8ff53df8 100644 --- a/xplan-ios/Main/Room/View/WishGift/View/View/XPWishGiftInfoView.m +++ b/xplan-ios/Main/Room/View/WishGift/View/View/XPWishGiftInfoView.m @@ -12,7 +12,6 @@ #import "NetImageView.h" #import "ThemeColor.h" #import "UIImage+Utils.h" -#import "XPSlider.h" ///Model #import "WishGiftInfoModel.h" @@ -28,7 +27,7 @@ ///进度 @property (nonatomic,strong) UILabel *progressLabel; ///进度条 -@property (nonatomic,strong) XPSlider *progressView; +@property (nonatomic,strong) UIProgressView *progressView; ///赠送按钮 @property (nonatomic,strong) UIButton *senderButton; ///完成按钮 @@ -128,7 +127,7 @@ if (value > 1) { value = 1; } - self.progressView.value = value; + self.progressView.progress = value; self.progressLabel.attributedText = [self createProgressAttribute]; self.progressLabel.textAlignment = NSTextAlignmentCenter; self.completionImageView.hidden = _giftInfo.targetNum != _giftInfo.actualNum; @@ -187,23 +186,40 @@ return _priceLabel; } -- (XPSlider *)progressView { +- (UIProgressView *)progressView { if(!_progressView) { - _progressView = [[XPSlider alloc] init]; - _progressView.enabled = NO; - [_progressView setMinimumTrackImage:[[UIImage gradientColorImageFromColors:@[[ThemeColor colorWithHexString:@"#FFA0C3"], [ThemeColor colorWithHexString:@"#C176FF"]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(1, 1)] resizableImageWithCapInsets:UIEdgeInsetsMake(0.1, 0.0, 0.1, 0.1) resizingMode:UIImageResizingModeStretch] forState:UIControlStateNormal]; - _progressView.thumbTintColor = [UIColor clearColor]; - _progressView.minimumValue = 0; - _progressView.maximumValue = 1; - _progressView.height = 5; + _progressView = [[UIProgressView alloc] init]; + _progressView.progressImage = [UIImage gradientColorImageFromColors:@[[ThemeColor colorWithHexString:@"#FFA0C3"], [ThemeColor colorWithHexString:@"#C176FF"]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(1, 1)]; _progressView.layer.masksToBounds = YES; _progressView.layer.cornerRadius = 2.5; - _progressView.continuous = NO; - [_progressView setMaximumTrackImage:[UIImage imageWithColor:[ThemeColor colorWithHexString:@"#17093E"]] forState:UIControlStateNormal]; + _progressView.trackImage = [UIImage imageWithColor:[ThemeColor colorWithHexString:@"#17093E"]]; } return _progressView; } +-(UIImage *)getGradientImageWithColors:(NSArray*)colors imgSize:(CGSize)imgSize +{ + NSMutableArray *arRef = [NSMutableArray array]; + for(UIColor *ref in colors) { + [arRef addObject:(id)ref.CGColor]; + + } + UIGraphicsBeginImageContextWithOptions(imgSize, YES, 1); + CGContextRef context = UIGraphicsGetCurrentContext(); + CGContextSaveGState(context); + CGColorSpaceRef colorSpace = CGColorGetColorSpace([[colors lastObject] CGColor]); + CGGradientRef gradient = CGGradientCreateWithColors(colorSpace, (CFArrayRef)arRef, NULL); + CGPoint start = CGPointMake(0.0, 0.0); + CGPoint end = CGPointMake(imgSize.width, imgSize.height); + CGContextDrawLinearGradient(context, gradient, start, end, kCGGradientDrawsBeforeStartLocation); + UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); + CGGradientRelease(gradient); + CGContextRestoreGState(context); + CGColorSpaceRelease(colorSpace); + UIGraphicsEndImageContext(); + return image; +} + - (UILabel *)progressLabel { if (!_progressLabel) { _progressLabel = [[UILabel alloc] init];