GuiZuBottomView.m 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. //
  2. // GuiZuBottomView.m
  3. // BuguLive
  4. //
  5. // Created by bugu on 2019/12/2.
  6. // Copyright © 2019 xfg. All rights reserved.
  7. //
  8. #import "GuiZuBottomView.h"
  9. @interface GuiZuBottomView ()
  10. @property(nonatomic, strong) UILabel *giftLabel;
  11. @property(nonatomic, strong) UILabel *moneyLabel;
  12. @property(nonatomic, strong) UIButton *sureBtn;
  13. @end
  14. @implementation GuiZuBottomView
  15. - (instancetype)initWithFrame:(CGRect)frame
  16. {
  17. self = [super initWithFrame:frame];
  18. if (self) {
  19. [self initUI];
  20. }
  21. return self;
  22. }
  23. - (void)initUI{
  24. self.backgroundColor = kWhiteColor;
  25. self.layer.shadowColor = [UIColor colorWithRed:211/255.0 green:211/255.0 blue:211/255.0 alpha:0.5].CGColor;
  26. self.layer.shadowOffset = CGSizeMake(0,-1);
  27. self.layer.shadowOpacity = 1;
  28. self.layer.shadowRadius = 2;
  29. _giftLabel = ({
  30. UILabel * label = [[UILabel alloc]init];
  31. label.textColor = [UIColor colorWithHexString:@"#333333"];
  32. label.font = [UIFont systemFontOfSize:14];
  33. label.text = @"";
  34. label;
  35. });
  36. _moneyLabel = ({
  37. UILabel * label = [[UILabel alloc]init];
  38. label.textColor = [UIColor colorWithHexString:@"#666666"];
  39. label.font = [UIFont systemFontOfSize:14];
  40. label.text = @"";
  41. label;
  42. });
  43. _sureBtn = ({
  44. UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
  45. [btn setBackgroundImage:[UIImage imageNamed:@"贵族立即开通按钮"] forState:UIControlStateNormal];
  46. // [btn setTitle:ASLocalizedString(@"知道啦")forState:UIControlStateNormal];
  47. // [btn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
  48. // btn.titleLabel.font = [UIFont systemFontOfSize:14];
  49. [btn addTarget:self action:@selector(sureAction) forControlEvents:UIControlEventTouchUpInside];
  50. btn;
  51. });
  52. [self addSubview:_giftLabel];
  53. [self addSubview:_moneyLabel];
  54. [self addSubview:_sureBtn];
  55. }
  56. - (void)sureAction{
  57. !self.buyBlock ? : self.buyBlock();
  58. }
  59. - (void)layoutSubviews {
  60. [super layoutSubviews];
  61. [_giftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  62. make.left.mas_equalTo(15);
  63. make.top.mas_equalTo(13);
  64. }];
  65. [_moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  66. make.left.mas_equalTo(15);
  67. make.bottom.mas_equalTo(-9);
  68. }];
  69. [_sureBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  70. make.right.mas_equalTo(-10);
  71. make.centerY.mas_equalTo(0);
  72. }];
  73. }
  74. - (void)setDataWithGift:(NSString *)gift money:(NSString *)money day:(NSString *)day{
  75. NSString * str = [NSString stringWithFormat:ASLocalizedString(@"立即获得%@钻石"),gift];
  76. NSMutableAttributedString *attribute = [[NSMutableAttributedString alloc]initWithString:str];
  77. [attribute setAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#BC8D50"]} range:NSMakeRange(ASLocalizedString(@"立即获得").length, gift.length)];
  78. [_giftLabel setAttributedText:attribute];
  79. _moneyLabel.text = [NSString stringWithFormat:ASLocalizedString(@"%@元/%@天"),money,day];
  80. }
  81. @end