113 lines
3.2 KiB
Mathematica
113 lines
3.2 KiB
Mathematica
![]() |
//
|
||
|
// XPMineRechargePayCollectionViewCell.m
|
||
|
// xplan-ios
|
||
|
//
|
||
|
// Created by XY on 2023/3/14.
|
||
|
//
|
||
|
|
||
|
#import "XPMineRechargePayCollectionViewCell.h"
|
||
|
#import "ThemeColor.h"
|
||
|
#import <Masonry.h>
|
||
|
#import "XPMinePayTypeModel.h"
|
||
|
|
||
|
@interface XPMineRechargePayCollectionViewCell()
|
||
|
|
||
|
/// 背景
|
||
|
@property (nonatomic, strong) UIView *bgView;
|
||
|
/// 选中背景
|
||
|
@property (nonatomic, strong) UIView *selectedBgView;
|
||
|
/// 支付方式
|
||
|
@property (nonatomic, strong, readwrite) UILabel *payTitleLabel;
|
||
|
/// 支付图标
|
||
|
@property (nonatomic, strong, readwrite) UIImageView *iconImageView;
|
||
|
|
||
|
@end
|
||
|
|
||
|
@implementation XPMineRechargePayCollectionViewCell
|
||
|
|
||
|
- (instancetype)initWithFrame:(CGRect)frame {
|
||
|
self = [super initWithFrame:frame];
|
||
|
if (self) {
|
||
|
[self createUI];
|
||
|
}
|
||
|
return self;
|
||
|
}
|
||
|
|
||
|
- (void)createUI {
|
||
|
[self.contentView addSubview:self.bgView];
|
||
|
[self.contentView addSubview:self.selectedBgView];
|
||
|
[self.contentView addSubview:self.payTitleLabel];
|
||
|
[self.contentView addSubview:self.iconImageView];
|
||
|
|
||
|
[self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.edges.mas_equalTo(self.contentView);
|
||
|
}];
|
||
|
[self.selectedBgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.edges.mas_equalTo(self.bgView);
|
||
|
}];
|
||
|
[self.payTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.centerY.mas_equalTo(0);
|
||
|
make.centerX.mas_equalTo(20);
|
||
|
}];
|
||
|
|
||
|
[self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.centerY.mas_equalTo(self.payTitleLabel);
|
||
|
make.width.height.mas_equalTo(30);
|
||
|
make.right.mas_equalTo(self.payTitleLabel.mas_left).offset(-12);
|
||
|
}];
|
||
|
}
|
||
|
|
||
|
#pragma mark - Getters And Setters
|
||
|
|
||
|
- (void)setPayTypeModel:(XPMinePayTypeModel *)payTypeModel {
|
||
|
_payTypeModel = payTypeModel;
|
||
|
self.payTitleLabel.text = _payTypeModel.payTitle;
|
||
|
self.iconImageView.image = [UIImage imageNamed:_payTypeModel.icon];
|
||
|
}
|
||
|
|
||
|
- (void)setSelectedStyle:(BOOL)selectedStyle {
|
||
|
_selectedStyle = selectedStyle;
|
||
|
self.selectedBgView.hidden = !selectedStyle;
|
||
|
}
|
||
|
|
||
|
- (UIView *)bgView {
|
||
|
if (!_bgView) {
|
||
|
_bgView = [[UIView alloc] init];
|
||
|
_bgView.backgroundColor = [ThemeColor colorWithHexString:@"#F8F8FA"];
|
||
|
_bgView.layer.cornerRadius = 5;
|
||
|
}
|
||
|
return _bgView;
|
||
|
}
|
||
|
|
||
|
- (UIView *)selectedBgView {
|
||
|
if (!_selectedBgView) {
|
||
|
_selectedBgView = [[UIView alloc] init];
|
||
|
_selectedBgView.backgroundColor = [[ThemeColor appMainColor] colorWithAlphaComponent:0.1];
|
||
|
_selectedBgView.layer.cornerRadius = 5;
|
||
|
_selectedBgView.layer.borderWidth = 1;
|
||
|
_selectedBgView.layer.borderColor = [ThemeColor appMainColor].CGColor;
|
||
|
_selectedBgView.hidden = YES;
|
||
|
}
|
||
|
return _selectedBgView;
|
||
|
}
|
||
|
|
||
|
- (UIImageView *)iconImageView {
|
||
|
if (!_iconImageView) {
|
||
|
_iconImageView = [[UIImageView alloc] init];
|
||
|
_iconImageView.contentMode = UIViewContentModeScaleAspectFit;
|
||
|
}
|
||
|
return _iconImageView;
|
||
|
}
|
||
|
|
||
|
- (UILabel *)payTitleLabel {
|
||
|
if (!_payTitleLabel) {
|
||
|
_payTitleLabel = [[UILabel alloc] init];
|
||
|
_payTitleLabel.textColor = [ThemeColor mainTextColor];
|
||
|
_payTitleLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightMedium];
|
||
|
}
|
||
|
return _payTitleLabel;
|
||
|
}
|
||
|
|
||
|
@end
|
||
|
|