BogoNobleBottomView.m 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. //
  2. // BogoNobleBottomView.m
  3. // BuguLive
  4. //
  5. // Created by 宋晨光 on 2021/4/24.
  6. // Copyright © 2021 xfg. All rights reserved.
  7. //
  8. #import "BogoNobleBottomView.h"
  9. @implementation BogoNobleBottomView
  10. - (instancetype)initWithFrame:(CGRect)frame
  11. {
  12. self = [super initWithFrame:frame];
  13. if (self) {
  14. [self setUpView];
  15. }
  16. return self;
  17. }
  18. -(void)setUpView{
  19. UIImageView *imgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kRealValue(68))];
  20. imgView.image = [UIImage imageNamed:@"bogo_noble_bottomBgImg"];
  21. imgView.userInteractionEnabled = YES;
  22. UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(kRealValue(10), 0, SCREEN_WIDTH - kRealValue(12 + 130 + 10), 40)];
  23. label.font = [UIFont systemFontOfSize:14];
  24. label.textColor = [UIColor colorWithHexString:@"#E5CBB7"];
  25. label.numberOfLines = 0;
  26. self.priceLabel = label;
  27. UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
  28. [btn setBackgroundImage:[UIImage imageNamed:@"bogo_noble_openBtnImg"] forState:UIControlStateNormal];
  29. [btn setTitle:ASLocalizedString(@"立即开通") forState:UIControlStateNormal];
  30. [btn setTitleColor:UIColor.blackColor forState:UIControlStateNormal];
  31. [btn addTarget:self action:@selector(clickOpenBtn:) forControlEvents:UIControlEventTouchUpInside];
  32. btn.frame = CGRectMake(kScreenW - kRealValue(12 + 130), 0, kRealValue(130), kRealValue(40));
  33. self.openBtn = btn;
  34. UILabel * subLabel = [[UILabel alloc]initWithFrame:CGRectMake(label.left, label.bottom, label.width, label.height)];
  35. subLabel.font = [UIFont systemFontOfSize:12];
  36. subLabel.textColor = [UIColor colorWithHexString:@"#999999"];
  37. subLabel.numberOfLines = 0;
  38. self.subLabel = subLabel;
  39. [self addSubview:imgView];
  40. [self addSubview:label];
  41. [self addSubview:subLabel];
  42. [self addSubview:btn];
  43. self.openBtn.centerY = self.height / 2;
  44. }
  45. - (void)setModel:(BogoNobleRechargeModel *)model {
  46. NSString * kaitongStr = [NSString stringWithFormat:@"%@%@:",ASLocalizedString(@"开通"),model.name];
  47. NSString *content = [NSString stringWithFormat:@" %@/%@",model.money,model.unit];
  48. // NSString * allStr = [NSString stringWithFormat:@"%@%@",kaitongStr,content];
  49. NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc]initWithString:kaitongStr];
  50. NSTextAttachment * textAttachment = [[NSTextAttachment alloc] init];
  51. textAttachment.image = [UIImage imageNamed:@"mine_noble_coinicon"];
  52. textAttachment.bounds = CGRectMake(0, 0, 13, 13);
  53. NSAttributedString * imgAttStr = [NSAttributedString attributedStringWithAttachment:textAttachment];
  54. [attStr appendAttributedString:imgAttStr];
  55. [attStr appendString:content];
  56. // NSRange range = [content rangeOfString:model.money];//范围
  57. // [attStr addAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#E5CBB7"],
  58. // NSFontAttributeName:[UIFont boldSystemFontOfSize:16]} range:range];//添加属性
  59. [self.priceLabel setAttributedText:attStr];
  60. self.subLabel.text = [NSString stringWithFormat:@"%@%@%@",ASLocalizedString(@"开通"),model.name,ASLocalizedString(@"获更多权益,享专属特权。")];
  61. }
  62. - (void)setIsOpen:(BOOL)isOpen{
  63. _isOpen = isOpen;
  64. if (isOpen) {
  65. [self.openBtn setBackgroundImage:[UIImage imageNamed:@"bogo_noble_Alert_ConfirmBtn_select"] forState:UIControlStateNormal];
  66. [self.openBtn setTitle:ASLocalizedString(@"已开通") forState:UIControlStateNormal];
  67. }else{
  68. [self.openBtn setBackgroundImage:[UIImage imageNamed:@"bogo_noble_openBtnImg"] forState:UIControlStateNormal];
  69. [self.openBtn setTitle:ASLocalizedString(@"立即开通") forState:UIControlStateNormal];
  70. }
  71. }
  72. -(void)clickOpenBtn:(UIButton *)sender{
  73. if (self.delegate && [self.delegate respondsToSelector:@selector(protocolClickOpenBtn)]) {
  74. [self.delegate protocolClickOpenBtn];
  75. }
  76. }
  77. @end