修改了进度条显示的问题

This commit is contained in:
fengshuo
2022-10-21 20:38:07 +08:00
parent a436ffc174
commit d99d5a8748
6 changed files with 55 additions and 71 deletions

View File

@@ -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 = "<group>"; };
E839533D276A0CDB00CF2F24 /* XPMineNameplateTableViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineNameplateTableViewCell.h; sourceTree = "<group>"; };
E839533E276A0CDB00CF2F24 /* XPMineNameplateTableViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMineNameplateTableViewCell.m; sourceTree = "<group>"; };
E83980642902728D0084BFC8 /* XPSlider.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPSlider.h; sourceTree = "<group>"; };
E83980652902728D0084BFC8 /* XPSlider.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPSlider.m; sourceTree = "<group>"; };
E839806729027D4A0084BFC8 /* room_wish_gift_sendCelebrate.svga */ = {isa = PBXFileReference; lastKnownFileType = file; path = room_wish_gift_sendCelebrate.svga; sourceTree = "<group>"; };
E8398069290288660084BFC8 /* XPMessageInfoModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMessageInfoModel.h; sourceTree = "<group>"; };
E839806A290288660084BFC8 /* XPMessageInfoModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMessageInfoModel.m; sourceTree = "<group>"; };
@@ -7395,8 +7392,6 @@
E89DCF5928FFF1AD001647EC /* XPWishGiftSectionView.m */,
E89DCF5E2900F4FB001647EC /* XPWishGiftEnterView.h */,
E89DCF5F2900F4FB001647EC /* XPWishGiftEnterView.m */,
E83980642902728D0084BFC8 /* XPSlider.h */,
E83980652902728D0084BFC8 /* XPSlider.m */,
);
path = View;
sourceTree = "<group>";
@@ -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 */,

View File

@@ -1,18 +0,0 @@
//
// XPSlider.h
// xplan-ios
//
// Created by 冯硕 on 2022/10/21.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface XPSlider : UISlider
///
@property (nonatomic,assign) CGFloat height;
@end
NS_ASSUME_NONNULL_END

View File

@@ -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

View File

@@ -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

View File

@@ -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) {

View File

@@ -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];