129 lines
4.1 KiB
Objective-C
129 lines
4.1 KiB
Objective-C
//
|
|
// YMIAPRechargeHeaderView.m
|
|
// YUMI
|
|
//
|
|
// Created by XY on 2023/2/21.
|
|
//
|
|
|
|
#import "XPIAPRechargeHeaderView.h"
|
|
#import <Masonry.h>
|
|
#import "YUMIMacroUitls.h"
|
|
|
|
#import "WalletInfoModel.h"
|
|
|
|
@interface XPIAPRechargeHeaderView()
|
|
|
|
/// 背景图
|
|
@property (nonatomic, strong) UIImageView *bgImageView;
|
|
///余额背景
|
|
@property(nonatomic,strong) UIImageView *balanceBgVeiw;
|
|
/// 余额文字
|
|
@property (nonatomic, strong) UILabel *balanceTextLabel;
|
|
/// 余额
|
|
@property (nonatomic, strong) UILabel *balanceLabel;
|
|
/// 💎
|
|
@property (nonatomic, strong) UIImageView *iconImageView;
|
|
|
|
@end
|
|
|
|
@implementation XPIAPRechargeHeaderView
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
self = [super initWithFrame:frame];
|
|
if (self) {
|
|
[self createUI];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)createUI {
|
|
[self addSubview:self.bgImageView];
|
|
[self.bgImageView addSubview:self.balanceBgVeiw];
|
|
[self.balanceBgVeiw addSubview:self.iconImageView];
|
|
[self.balanceBgVeiw addSubview:self.balanceTextLabel];
|
|
[self.balanceBgVeiw addSubview:self.balanceLabel];
|
|
|
|
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.edges.equalTo(self);
|
|
}];
|
|
[self.balanceBgVeiw mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.width.mas_equalTo(kGetScaleWidth(343));
|
|
make.height.mas_equalTo(kGetScaleWidth(86));
|
|
make.centerX.equalTo(self.bgImageView);
|
|
make.bottom.mas_equalTo(-kGetScaleWidth(22));
|
|
}];
|
|
|
|
[self.balanceTextLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerX.equalTo(self.balanceBgVeiw).mas_offset(kGetScaleWidth(13));
|
|
make.top.mas_equalTo(kGetScaleWidth(14));
|
|
make.height.mas_equalTo(kGetScaleWidth(14));
|
|
}];
|
|
[self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.width.height.mas_equalTo(kGetScaleWidth(21));
|
|
make.trailing.equalTo(self.balanceTextLabel.mas_leading).mas_offset(-kGetScaleWidth(5));
|
|
make.centerY.equalTo(self.balanceTextLabel);
|
|
|
|
}];
|
|
[self.balanceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.bottom.mas_equalTo(-kGetScaleWidth(14));
|
|
make.centerX.equalTo(self.balanceBgVeiw);
|
|
make.leading.trailing.equalTo(self.balanceBgVeiw).inset(kGetScaleWidth(10));
|
|
}];
|
|
}
|
|
|
|
- (void)setWalletInfo:(WalletInfoModel *)walletInfo {
|
|
_walletInfo = walletInfo;
|
|
if (_walletInfo) {
|
|
self.balanceLabel.text = walletInfo.diamonds;
|
|
}
|
|
}
|
|
|
|
#pragma mark - 懒加载
|
|
|
|
- (UIImageView *)bgImageView {
|
|
if (!_bgImageView) {
|
|
_bgImageView = [[UIImageView alloc] init];
|
|
UIImage *image = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0x13E2F5),UIColorFromRGB(0x9DB4FF),UIColorFromRGB(0xCC67FF)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(KScreenWidth, kGetScaleWidth(123))];
|
|
_bgImageView.image = image;
|
|
}
|
|
return _bgImageView;
|
|
}
|
|
- (UIImageView *)balanceBgVeiw{
|
|
if(!_balanceBgVeiw){
|
|
_balanceBgVeiw = [UIImageView new];
|
|
_balanceBgVeiw.image = kImage(@"mine_recharge_balance_bg");
|
|
}
|
|
return _balanceBgVeiw;
|
|
}
|
|
- (UILabel *)balanceTextLabel {
|
|
if (!_balanceTextLabel) {
|
|
_balanceTextLabel = [[UILabel alloc] init];
|
|
_balanceTextLabel.textColor = UIColorFromRGB(0x333333);
|
|
_balanceTextLabel.font = kFontRegular(14);
|
|
_balanceTextLabel.text = YMLocalizedString(@"XPIAPRechargeHeaderView0");
|
|
}
|
|
return _balanceTextLabel;
|
|
}
|
|
|
|
- (UILabel *)balanceLabel {
|
|
if (!_balanceLabel) {
|
|
_balanceLabel = [[UILabel alloc] init];
|
|
_balanceLabel.textColor = UIColorFromRGB(0x1F1B4F);
|
|
_balanceLabel.font = kFontMedium(32);
|
|
_balanceLabel.textAlignment = NSTextAlignmentCenter;
|
|
_balanceLabel.text = @"0";
|
|
_balanceLabel.adjustsFontSizeToFitWidth = YES;
|
|
}
|
|
return _balanceLabel;
|
|
}
|
|
- (UIImageView *)iconImageView {
|
|
if (!_iconImageView) {
|
|
_iconImageView = [[UIImageView alloc] init];
|
|
_iconImageView.contentMode = UIViewContentModeScaleAspectFit;
|
|
_iconImageView.image = [UIImage imageNamed:@"mine_main_recharge_diamond"];
|
|
}
|
|
return _iconImageView;
|
|
}
|
|
|
|
@end
|