Files
yinmeng-ios/xplan-ios/Main/ModuleKit/SendGiftView/View/Cell/XPGiftCountCollectionViewCell.m
2022-01-14 15:48:47 +08:00

104 lines
2.6 KiB
Objective-C

//
// XPGiftCountCollectionViewCell.m
// xplan-ios
//
// Created by 冯硕 on 2021/11/11.
//
#import "XPGiftCountCollectionViewCell.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "ThemeColor+SendGift.h"
///Model
#import "XPGiftCountModel.h"
@interface XPGiftCountCollectionViewCell ()
///显示标题
@property (nonatomic,strong) UILabel *titleLabel;
///显示礼物个数
@property (nonatomic,strong) UILabel *countLabel;
///显示其他数额的箭头
@property (nonatomic,strong) UIImageView *arrowImageView;
@end
@implementation XPGiftCountCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Private Method
- (void)initSubViews {
[self.contentView addSubview:self.titleLabel];
[self.contentView addSubview:self.countLabel];
[self.contentView addSubview:self.arrowImageView];
}
- (void)initSubViewConstraints {
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(20);
make.centerY.mas_equalTo(self.contentView);
}];
[self.countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(-20);
make.centerY.mas_equalTo(0);
make.left.mas_greaterThanOrEqualTo(self.titleLabel.mas_right).offset(5);
}];
[self.arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(-20);
make.centerY.mas_equalTo(0);
make.width.height.mas_equalTo(10);
}];
}
#pragma mark - Getters And Setters
- (void)setCountModel:(XPGiftCountModel *)countModel {
_countModel = countModel;
if (_countModel) {
self.titleLabel.text = _countModel.title;
self.countLabel.text = _countModel.giftNumber;
if (_countModel.isCustomCount) {
self.arrowImageView.hidden = NO;
} else {
self.arrowImageView.hidden = YES;
}
}
}
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.font = [UIFont systemFontOfSize:13];
_titleLabel.textColor = [ThemeColor giftCountTitleColor];
}
return _titleLabel;
}
- (UILabel *)countLabel {
if (!_countLabel) {
_countLabel = [[UILabel alloc] init];
_countLabel.font = [UIFont systemFontOfSize:14];
_countLabel.textColor = [ThemeColor appMainColor];
_countLabel.textAlignment = NSTextAlignmentRight;
}
return _countLabel;
}
- (UIImageView *)arrowImageView {
if (!_arrowImageView) {
_arrowImageView = [[UIImageView alloc] init];
_arrowImageView.image = [UIImage imageNamed:@"gift_bar_recharge_arrow"];
_arrowImageView.hidden = YES;
}
return _arrowImageView;
}
@end