97 lines
3.2 KiB
Objective-C
97 lines
3.2 KiB
Objective-C
//
|
|
// XPPrivilegeCardGiftCell.m
|
|
// xplan-ios
|
|
//
|
|
// Created by duoban on 2023/7/24.
|
|
//
|
|
|
|
#import "XPPrivilegeCardGiftCell.h"
|
|
@interface XPPrivilegeCardGiftCell()
|
|
///背景
|
|
@property(nonatomic,strong) NetImageView *bgImageView;
|
|
///时间
|
|
@property(nonatomic,strong) UILabel *timeView;
|
|
///标题
|
|
@property(nonatomic,strong) UILabel *titleVeiw;
|
|
///蒙层
|
|
@property(nonatomic,strong) UIImageView *curMaskView;
|
|
@end
|
|
|
|
@implementation XPPrivilegeCardGiftCell
|
|
-(instancetype)initWithFrame:(CGRect)frame{
|
|
self = [super initWithFrame:frame];
|
|
if(self){
|
|
[self installUI];
|
|
[self installConstraints];
|
|
}
|
|
return self;
|
|
}
|
|
-(void)installUI{
|
|
[self.contentView addSubview:self.bgImageView];
|
|
[self.bgImageView addSubview:self.timeView];
|
|
[self.bgImageView addSubview:self.curMaskView];
|
|
[self.contentView addSubview:self.titleVeiw];
|
|
}
|
|
-(void)installConstraints{
|
|
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.leading.top.equalTo(self.contentView);
|
|
make.width.mas_equalTo(kGetScaleWidth(160));
|
|
make.height.mas_equalTo(kGetScaleWidth(90));
|
|
}];
|
|
[self.curMaskView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.leading.trailing.bottom.equalTo(self.bgImageView);
|
|
make.height.mas_equalTo(kGetScaleWidth(40));
|
|
}];
|
|
[self.timeView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.bottom.mas_equalTo(-kGetScaleWidth(4));
|
|
make.leading.trailing.equalTo(self.contentView).inset(kGetScaleWidth(5));
|
|
}];
|
|
[self.titleVeiw mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.equalTo(self.bgImageView.mas_bottom).mas_offset(kGetScaleWidth(6));
|
|
make.leading.trailing.equalTo(self.contentView).inset(kGetScaleWidth(5));
|
|
make.height.mas_equalTo(kGetScaleWidth(14));
|
|
}];
|
|
}
|
|
- (void)setCardModel:(XPPrivilegeCardItemModel *)cardModel{
|
|
_cardModel = cardModel;
|
|
_titleVeiw.text = _cardModel.cardName;
|
|
_timeView.text = [NSString stringWithFormat:@"有效期至:%@",_cardModel.expireTime];
|
|
_bgImageView.imageUrl = _cardModel.cardUrl;
|
|
_bgImageView.layer.borderWidth = _cardModel.isSelected ? 2 : 0;
|
|
}
|
|
|
|
|
|
#pragma mark - 懒加载
|
|
- (NetImageView *)bgImageView{
|
|
if(!_bgImageView){
|
|
_bgImageView = [[NetImageView alloc]init];
|
|
_bgImageView.layer.cornerRadius = kGetScaleWidth(12);
|
|
_bgImageView.layer.masksToBounds = YES;
|
|
_bgImageView.layer.borderColor = UIColorFromRGB(0xFFDA24).CGColor;
|
|
_bgImageView.contentMode = UIViewContentModeScaleAspectFill;
|
|
}
|
|
return _bgImageView;
|
|
}
|
|
- (UILabel *)timeView{
|
|
if(!_timeView){
|
|
_timeView = [UILabel labelInitWithText:@"" font:kFontMedium(8) textColor:[UIColor whiteColor]];
|
|
_timeView.textAlignment = NSTextAlignmentCenter;
|
|
}
|
|
return _timeView;
|
|
}
|
|
-(UILabel *)titleVeiw{
|
|
if(!_titleVeiw){
|
|
_titleVeiw = [UILabel labelInitWithText:@"" font:kFontMedium(10) textColor:[UIColor whiteColor]];
|
|
_titleVeiw.textAlignment = NSTextAlignmentCenter;
|
|
}
|
|
return _titleVeiw;
|
|
}
|
|
- (UIImageView *)curMaskView{
|
|
if(!_curMaskView){
|
|
_curMaskView = [UIImageView new];
|
|
_curMaskView.image = kImage(@"room_Privilege_Card_mask");
|
|
}
|
|
return _curMaskView;
|
|
}
|
|
@end
|