115 lines
3.1 KiB
Objective-C
115 lines
3.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;
|
|
|
|
|
|
@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.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(339));
|
|
make.height.mas_equalTo(kGetScaleWidth(118));
|
|
make.centerX.equalTo(self.bgImageView);
|
|
make.bottom.mas_equalTo(-kGetScaleWidth(0));
|
|
}];
|
|
|
|
[self.balanceTextLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.leading.mas_equalTo(kGetScaleWidth(33));
|
|
make.top.mas_equalTo(kGetScaleWidth(36));
|
|
make.height.mas_equalTo(kGetScaleWidth(14));
|
|
}];
|
|
|
|
[self.balanceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.equalTo(self.balanceTextLabel.mas_bottom).mas_offset(kGetScaleWidth(10));
|
|
make.leading.mas_equalTo(kGetScaleWidth(33));
|
|
}];
|
|
}
|
|
|
|
- (void)setWalletInfo:(WalletInfoModel *)walletInfo {
|
|
_walletInfo = walletInfo;
|
|
if (_walletInfo) {
|
|
self.balanceLabel.text = walletInfo.diamonds;
|
|
}
|
|
}
|
|
|
|
#pragma mark - 懒加载
|
|
|
|
- (UIImageView *)bgImageView {
|
|
if (!_bgImageView) {
|
|
_bgImageView = [[UIImageView alloc] init];
|
|
|
|
_bgImageView.image = kImage(@"ms_mine_top_bg");
|
|
}
|
|
return _bgImageView;
|
|
}
|
|
- (UIImageView *)balanceBgVeiw{
|
|
if(!_balanceBgVeiw){
|
|
_balanceBgVeiw = [UIImageView new];
|
|
_balanceBgVeiw.image = kImage(@"ms_mine_coin_bg");
|
|
}
|
|
return _balanceBgVeiw;
|
|
}
|
|
- (UILabel *)balanceTextLabel {
|
|
if (!_balanceTextLabel) {
|
|
_balanceTextLabel = [[UILabel alloc] init];
|
|
_balanceTextLabel.textColor = UIColorFromRGB(0x9F4805);
|
|
_balanceTextLabel.font = kFontBold(15);
|
|
_balanceTextLabel.text = YMLocalizedString(@"XPIAPRechargeHeaderView0");
|
|
}
|
|
return _balanceTextLabel;
|
|
}
|
|
|
|
- (UILabel *)balanceLabel {
|
|
if (!_balanceLabel) {
|
|
_balanceLabel = [[UILabel alloc] init];
|
|
_balanceLabel.textColor = UIColorFromRGB(0xFFFBD5);
|
|
_balanceLabel.font = kFontBold(24);
|
|
_balanceLabel.textAlignment = NSTextAlignmentCenter;
|
|
_balanceLabel.text = @"0";
|
|
_balanceLabel.adjustsFontSizeToFitWidth = YES;
|
|
}
|
|
return _balanceLabel;
|
|
}
|
|
|
|
|
|
@end
|