| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- //
- // BogoNobleBottomView.m
- // BuguLive
- //
- // Created by 宋晨光 on 2021/4/24.
- // Copyright © 2021 xfg. All rights reserved.
- //
- #import "BogoNobleBottomView.h"
- @implementation BogoNobleBottomView
- - (instancetype)initWithFrame:(CGRect)frame
- {
- self = [super initWithFrame:frame];
- if (self) {
- [self setUpView];
- }
- return self;
- }
- -(void)setUpView{
- UIImageView *imgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kRealValue(68))];
- imgView.image = [UIImage imageNamed:@"bogo_noble_bottomBgImg"];
- imgView.userInteractionEnabled = YES;
-
- UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(kRealValue(10), 0, SCREEN_WIDTH - kRealValue(12 + 130 + 10), 40)];
- label.font = [UIFont systemFontOfSize:14];
- label.textColor = [UIColor colorWithHexString:@"#E5CBB7"];
- label.numberOfLines = 0;
- self.priceLabel = label;
-
- UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
- [btn setBackgroundImage:[UIImage imageNamed:@"bogo_noble_openBtnImg"] forState:UIControlStateNormal];
- [btn setTitle:ASLocalizedString(@"立即开通") forState:UIControlStateNormal];
- [btn setTitleColor:UIColor.blackColor forState:UIControlStateNormal];
- [btn addTarget:self action:@selector(clickOpenBtn:) forControlEvents:UIControlEventTouchUpInside];
- btn.frame = CGRectMake(kScreenW - kRealValue(12 + 130), 0, kRealValue(130), kRealValue(40));
- self.openBtn = btn;
-
- UILabel * subLabel = [[UILabel alloc]initWithFrame:CGRectMake(label.left, label.bottom, label.width, label.height)];
- subLabel.font = [UIFont systemFontOfSize:12];
- subLabel.textColor = [UIColor colorWithHexString:@"#999999"];
- subLabel.numberOfLines = 0;
- self.subLabel = subLabel;
-
- [self addSubview:imgView];
- [self addSubview:label];
- [self addSubview:subLabel];
- [self addSubview:btn];
-
-
- self.openBtn.centerY = self.height / 2;
- }
- - (void)setModel:(BogoNobleRechargeModel *)model {
-
- NSString * kaitongStr = [NSString stringWithFormat:@"%@%@:",ASLocalizedString(@"开通"),model.name];
-
- NSString *content = [NSString stringWithFormat:@" %@/%@",model.money,model.unit];
- // NSString * allStr = [NSString stringWithFormat:@"%@%@",kaitongStr,content];
-
- NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc]initWithString:kaitongStr];
-
- NSTextAttachment * textAttachment = [[NSTextAttachment alloc] init];
- textAttachment.image = [UIImage imageNamed:@"mine_noble_coinicon"];
- textAttachment.bounds = CGRectMake(0, 0, 13, 13);
- NSAttributedString * imgAttStr = [NSAttributedString attributedStringWithAttachment:textAttachment];
-
- [attStr appendAttributedString:imgAttStr];
- [attStr appendString:content];
-
- // NSRange range = [content rangeOfString:model.money];//范围
- // [attStr addAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#E5CBB7"],
- // NSFontAttributeName:[UIFont boldSystemFontOfSize:16]} range:range];//添加属性
-
- [self.priceLabel setAttributedText:attStr];
-
- self.subLabel.text = [NSString stringWithFormat:@"%@%@%@",ASLocalizedString(@"开通"),model.name,ASLocalizedString(@"获更多权益,享专属特权。")];
- }
- - (void)setIsOpen:(BOOL)isOpen{
- _isOpen = isOpen;
- if (isOpen) {
- [self.openBtn setBackgroundImage:[UIImage imageNamed:@"bogo_noble_Alert_ConfirmBtn_select"] forState:UIControlStateNormal];
- [self.openBtn setTitle:ASLocalizedString(@"已开通") forState:UIControlStateNormal];
- }else{
- [self.openBtn setBackgroundImage:[UIImage imageNamed:@"bogo_noble_openBtnImg"] forState:UIControlStateNormal];
- [self.openBtn setTitle:ASLocalizedString(@"立即开通") forState:UIControlStateNormal];
- }
-
-
-
- }
- -(void)clickOpenBtn:(UIButton *)sender{
- if (self.delegate && [self.delegate respondsToSelector:@selector(protocolClickOpenBtn)]) {
- [self.delegate protocolClickOpenBtn];
- }
- }
- @end
|