Files
featherVoice/QXLive/Mine(音域)/View/每日任务/QXProgressView.m
2025-08-08 10:49:36 +08:00

70 lines
2.0 KiB
Objective-C

//
// QXProgressView.m
// QXLive
//
// Created by 启星 on 2025/5/26.
//
#import "QXProgressView.h"
@interface QXProgressView()
@property (nonatomic,strong)UIView *bgView;
@property (nonatomic,strong)UIView *progressView;
@property (nonatomic,strong)UILabel *progressLabel;
@end
@implementation QXProgressView
- (instancetype)init
{
self = [super init];
if (self) {
[self initSubviews];
}
return self;
}
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self initSubviews];
}
return self;
}
-(void)initSubviews{
self.bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.width-32, self.height)];
[self addSubview:self.bgView];
self.bgView.backgroundColor = RGB16(0xFFB8CD);
[self.bgView addRoundedCornersWithRadius:self.height/2];
self.progressView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 2, self.height)];
[self addSubview:self.progressView];
self.progressView.backgroundColor = RGB16(0xE24171);
[self.progressView addRoundedCornersWithRadius:self.height/2];
self.progressLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.width-30, 0, 30, self.height)];
self.progressLabel.textColor = RGB16(0xE24171);
self.progressLabel.font = [UIFont systemFontOfSize:10];
[self addSubview:self.progressLabel];
}
-(void)setBgColor:(UIColor *)bgColor{
_bgColor = bgColor;
self.bgView.backgroundColor = bgColor;
}
-(void)setProgressColor:(UIColor *)progressColor{
_progressColor = progressColor;
self.progressView.backgroundColor = progressColor;
}
-(void)setProgressTitleColor:(UIColor *)progressTitleColor{
_progressTitleColor = progressTitleColor;
self.progressLabel.textColor = progressTitleColor;
}
-(void)setProgress:(double)progress{
_progress = progress;
self.progressLabel.text = [NSString stringWithFormat:@"%d%%",(int)(progress*100)];
[UIView animateWithDuration:0.3 animations:^{
self.progressView.width = (self.width-32)*progress;
}];
}
@end