MOTeDownloadView.m 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //
  2. // MOTeDownloadView.m
  3. // MiMoLive
  4. //
  5. // Created by SuperC on 2025/2/28.
  6. //
  7. #import "MOTeDownloadView.h"
  8. #import "ZJCircleProgressView.h"
  9. @interface MOTeDownloadView ()
  10. @property (nonatomic, strong) ZJCircleProgressView *progressView;
  11. @property (nonatomic, strong) UIImageView *tagIcon;
  12. @end
  13. @implementation MOTeDownloadView
  14. - (instancetype)initWithFrame:(CGRect)frame{
  15. self = [super initWithFrame:frame];
  16. if(self){
  17. [self setUIProperty];
  18. }
  19. return self;
  20. }
  21. - (void)setUIProperty{
  22. self.backgroundColor = [MOTools colorWithHexString:@"#000000" alpha:0.3];
  23. self.layer.cornerRadius = self.bounds.size.width / 2.0;
  24. self.layer.masksToBounds = YES;
  25. [self addSubview:self.progressView];
  26. [self.progressView mas_makeConstraints:^(MASConstraintMaker *make) {
  27. make.width.height.equalTo(@40.0);
  28. make.centerX.equalTo(self);
  29. make.centerY.equalTo(self);
  30. }];
  31. [self addSubview:self.tagIcon];
  32. [self.tagIcon mas_makeConstraints:^(MASConstraintMaker *make) {
  33. make.width.height.equalTo(@30.0);
  34. make.centerX.equalTo(self);
  35. make.centerY.equalTo(self);
  36. }];
  37. // 获取本地文件的路径
  38. NSString *path = [[NSBundle mainBundle] pathForResource:@"mo_download" ofType:@"gif"];
  39. NSURL *gifURL = [NSURL fileURLWithPath:path];
  40. // 使用 SDWebImage 加载本地 GIF 动图
  41. [self.tagIcon sd_setImageWithURL:gifURL placeholderImage:nil options:SDWebImageProgressiveLoad completed:nil];
  42. }
  43. - (void)setProgress:(CGFloat)progress{
  44. _progress = progress;
  45. self.progressView.progress = progress;
  46. }
  47. - (ZJCircleProgressView *)progressView{
  48. if(!_progressView){
  49. _progressView = [[ZJCircleProgressView alloc] initWithFrame:CGRectMake(0.0, 0.0, 40.0, 40.0)];
  50. _progressView.lineWidth = 3.0;
  51. _progressView.trackBackgroundColor = [MOTools colorWithHexString:@"#333333" alpha:0.5];
  52. _progressView.trackColor = [UIColor whiteColor];
  53. }
  54. return _progressView;
  55. }
  56. - (UIImageView *)tagIcon{
  57. if(!_tagIcon){
  58. _tagIcon = [[UIImageView alloc] init];
  59. _tagIcon.contentMode = UIViewContentModeScaleAspectFit;
  60. }
  61. return _tagIcon;
  62. }
  63. @end