// // YOUPAILZLevelView.m // VQU // // Created by CY on 2021/9/1. // Copyright © 2021 MS. All rights reserved. // #import "YOUPAILZLevelView.h" @interface YOUPAILZLevelView () @property (nonatomic, weak) UIImageView *youpaipiconImgV; @property (nonatomic, weak) UIImageView *youpaipbgImgV; @property (nonatomic, weak) UILabel *youpaipcontentL; @property (nonatomic, weak) UILabel *youpaiplevelL; @end @implementation YOUPAILZLevelView - (instancetype)init{ if (self = [super init]) { [self youpaifinitUI]; } return self; } - (void)youpaifinitUI{ UIImageView *youpaipbgImgV = [[UIImageView alloc] init]; [self addSubview:youpaipbgImgV]; self.youpaipbgImgV = youpaipbgImgV; UIImageView *youpaipiconImgV = [[UIImageView alloc] init]; [self addSubview:youpaipiconImgV]; self.youpaipiconImgV = youpaipiconImgV; UILabel *contentL = [[UILabel alloc] init]; contentL.font = LCBoldFont(9.0f); contentL.textColor = [UIColor whiteColor]; [self addSubview:contentL]; self.youpaipcontentL = contentL; UILabel *youpaiplevelL = [[UILabel alloc] init]; youpaiplevelL.font = LZZhenyanGBFont(4.5f); youpaiplevelL.textColor = [UIColor whiteColor]; [self addSubview:youpaiplevelL]; self.youpaiplevelL = youpaiplevelL; [youpaiplevelL mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(youpaipiconImgV.mas_right).offset(-3.0f); make.bottom.equalTo(youpaipiconImgV.mas_bottom).offset(-2.0f); }]; } - (void)youpaifreloadWithIcon:(NSString *)icon iconWidth:(CGFloat)iconWidth bgImg:(NSString *)bgImg bgImgWidth:(CGFloat)bgImgWidth levelName:(NSString *)levelName level:(NSInteger)level{ [self.youpaipiconImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:icon]]; [self.youpaipbgImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:bgImg]]; self.youpaipcontentL.text = levelName; if (level != 0) { self.youpaiplevelL.text = [NSString stringWithFormat:@"%@",@(level)]; }else{ self.youpaiplevelL.text = @""; } self.youpaipiconImgV.frame = CGRectMake(0.0f, 0.0f, iconWidth, 17.0f); self.youpaipbgImgV.frame = CGRectMake(iconWidth / 2.0f, 1.5f, bgImgWidth, self.youpaipiconImgV.mj_h - 3.0f); self.mj_size = CGSizeMake(iconWidth / 2.0f + bgImgWidth, 17.0f); self.youpaipcontentL.frame = CGRectMake(iconWidth, self.youpaipbgImgV.mj_y, self.mj_w - iconWidth, self.youpaipbgImgV.mj_h); } @end