YOUPAILZLevelView.m 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //
  2. // YOUPAILZLevelView.m
  3. // VQU
  4. //
  5. // Created by CY on 2021/9/1.
  6. // Copyright © 2021 MS. All rights reserved.
  7. //
  8. #import "YOUPAILZLevelView.h"
  9. @interface YOUPAILZLevelView ()
  10. @property (nonatomic, weak) UIImageView *youpaipiconImgV;
  11. @property (nonatomic, weak) UIImageView *youpaipbgImgV;
  12. @property (nonatomic, weak) UILabel *youpaipcontentL;
  13. @property (nonatomic, weak) UILabel *youpaiplevelL;
  14. @end
  15. @implementation YOUPAILZLevelView
  16. - (instancetype)init{
  17. if (self = [super init]) {
  18. [self youpaifinitUI];
  19. }
  20. return self;
  21. }
  22. - (void)youpaifinitUI{
  23. UIImageView *youpaipbgImgV = [[UIImageView alloc] init];
  24. [self addSubview:youpaipbgImgV];
  25. self.youpaipbgImgV = youpaipbgImgV;
  26. UIImageView *youpaipiconImgV = [[UIImageView alloc] init];
  27. [self addSubview:youpaipiconImgV];
  28. self.youpaipiconImgV = youpaipiconImgV;
  29. UILabel *contentL = [[UILabel alloc] init];
  30. contentL.font = LCBoldFont(9.0f);
  31. contentL.textColor = [UIColor whiteColor];
  32. [self addSubview:contentL];
  33. self.youpaipcontentL = contentL;
  34. UILabel *youpaiplevelL = [[UILabel alloc] init];
  35. youpaiplevelL.font = LZZhenyanGBFont(4.5f);
  36. youpaiplevelL.textColor = [UIColor whiteColor];
  37. [self addSubview:youpaiplevelL];
  38. self.youpaiplevelL = youpaiplevelL;
  39. [youpaiplevelL mas_makeConstraints:^(MASConstraintMaker *make) {
  40. make.right.equalTo(youpaipiconImgV.mas_right).offset(-3.0f);
  41. make.bottom.equalTo(youpaipiconImgV.mas_bottom).offset(-2.0f);
  42. }];
  43. }
  44. - (void)youpaifreloadWithIcon:(NSString *)icon iconWidth:(CGFloat)iconWidth bgImg:(NSString *)bgImg bgImgWidth:(CGFloat)bgImgWidth levelName:(NSString *)levelName level:(NSInteger)level{
  45. [self.youpaipiconImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:icon]];
  46. [self.youpaipbgImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:bgImg]];
  47. self.youpaipcontentL.text = levelName;
  48. if (level != 0) {
  49. self.youpaiplevelL.text = [NSString stringWithFormat:@"%@",@(level)];
  50. }else{
  51. self.youpaiplevelL.text = @"";
  52. }
  53. self.youpaipiconImgV.frame = CGRectMake(0.0f, 0.0f, iconWidth, 17.0f);
  54. self.youpaipbgImgV.frame = CGRectMake(iconWidth / 2.0f, 1.5f, bgImgWidth, self.youpaipiconImgV.mj_h - 3.0f);
  55. self.mj_size = CGSizeMake(iconWidth / 2.0f + bgImgWidth, 17.0f);
  56. self.youpaipcontentL.frame = CGRectMake(iconWidth, self.youpaipbgImgV.mj_y, self.mj_w - iconWidth, self.youpaipbgImgV.mj_h);
  57. }
  58. @end