HRPopView.m 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. //
  2. // HRPopView.m
  3. // VQU
  4. //
  5. // Created by xiaohaoran on 2021/10/27.
  6. // Copyright © 2021 MS. All rights reserved.
  7. //
  8. #import "HRPopView.h"
  9. #define MarginPadding (17.0f)
  10. @interface HRPopView ()
  11. @property(nonatomic,strong)UITextView *contTextV;
  12. @end
  13. @implementation HRPopView
  14. - (instancetype)initWithFrame:(CGRect)frame Model:(YOUPAILZEndLiveHintModel *)model{
  15. if (self = [super initWithFrame:CGRectZero]) {
  16. // _model = model;
  17. [self youpaifsetSubView];
  18. }
  19. return self;
  20. }
  21. - (void)youpaifsetSubView {
  22. [[UIApplication sharedApplication].keyWindow addSubview:self];
  23. // [UIView animateWithDuration:0.25 animations:^{
  24. self.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
  25. // }];
  26. [self youpaifinitUI];
  27. }
  28. - (void)youpaifinitUI{
  29. CGFloat bgViewHight = 0;
  30. UIView *bgView = [UIView new];
  31. [self addSubview:bgView];
  32. [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
  33. make.left.mas_equalTo(14);
  34. make.right.mas_equalTo(-14);
  35. make.top.mas_equalTo(125);
  36. make.height.mas_equalTo(307);
  37. }];
  38. bgView.backgroundColor = [UIColor clearColor];
  39. //arrView
  40. UIView *arrowView = [UIView new];
  41. [bgView addSubview:arrowView];
  42. [arrowView mas_makeConstraints:^(MASConstraintMaker *make) {
  43. make.left.mas_equalTo(0);
  44. make.right.mas_equalTo(0);
  45. make.top.mas_equalTo(0);
  46. make.height.mas_equalTo(0);
  47. }];
  48. arrowView.backgroundColor = [UIColor clearColor];
  49. UIImageView *arrowV = [[UIImageView alloc] init];
  50. [arrowView addSubview:arrowV];
  51. [arrowV mas_makeConstraints:^(MASConstraintMaker *make) {
  52. make.left.mas_equalTo(17.5);
  53. make.top.mas_equalTo(0);
  54. make.size.mas_equalTo(CGSizeMake(19, 9));
  55. }];
  56. arrowV.image = [UIImage imageNamed:@"vqu_images_L_arrow_top"];
  57. bgViewHight+=9;
  58. UIView *subBgView = [UIView new];
  59. [bgView addSubview:subBgView];
  60. [subBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  61. make.left.mas_equalTo(0);
  62. make.right.mas_equalTo(0);
  63. make.top.mas_equalTo(arrowV.mas_bottom).offset(-2);
  64. make.height.mas_equalTo(307);
  65. }];
  66. subBgView.backgroundColor = LCBkgColor;
  67. subBgView.layer.cornerRadius = 5;
  68. subBgView.layer.masksToBounds = YES;
  69. subBgView.layer.borderWidth = 0.5;
  70. subBgView.layer.borderColor = HexColorFromRGB(0x4F4B5B).CGColor;
  71. //标题
  72. UILabel *titleL = [[UILabel alloc] init];
  73. [subBgView addSubview:titleL];
  74. [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
  75. make.top.mas_equalTo(20);
  76. make.left.mas_equalTo(17);
  77. }];
  78. titleL.font = [UIFont systemFontOfSize:18];
  79. titleL.textColor = HexColorFromRGB(0xffffff);
  80. titleL.text = @"房间公告";
  81. bgViewHight+=18;
  82. NSString *contentStr = @"这里是蓝朵朵每天和朋友啰嗦的小屋,\n期待每天10-1220-22与你们的遇见,\n给你们讲我们这些年不曾告诉别人的故事,\n也守着你们听你们只想告诉我们的故事,\n如果声音有温度,朵朵愿用声音温暖你们的心,\n守着你们,陪着你们在相遇的每一分每一秒";
  83. //内容
  84. UITextView* contTextView = [[UITextView alloc]init];
  85. self.contTextV = contTextView;
  86. [self addSubview:contTextView];
  87. [contTextView mas_makeConstraints:^(MASConstraintMaker *make) {
  88. make.left.mas_equalTo(MarginPadding);
  89. make.top.mas_equalTo(titleL.mas_bottom).offset(20);
  90. make.right.mas_equalTo(-MarginPadding);
  91. make.height.mas_equalTo(120);
  92. }];
  93. [contTextView setBackgroundColor:[UIColor clearColor]];
  94. contTextView.scrollEnabled = NO;
  95. // contTextView.backgroundColor = [UIColor redColor];
  96. // contTextView.userInteractionEnabled = YES;
  97. // contTextView.numberOfLines = 0;
  98. // contTextView.lineBreakMode = NSLineBreakByWordWrapping;
  99. contTextView.textColor = [UIColor whiteColor];
  100. contTextView.font = [UIFont systemFontOfSize:14];
  101. contTextView.text = nil;
  102. contTextView.text = contentStr;
  103. contTextView.editable = NO;
  104. // contTextView.layer.masksToBounds = YES;
  105. CGSize constraint = CGSizeMake(contTextView.contentSize.width, CGFLOAT_MAX);
  106. // CGSize size = [self.dyModel.content sizeWithFont:[UIFont systemFontOfSize:17] constrainedToSize:constraint lineBreakMode:NSLineBreakByWordWrapping];
  107. CGRect rect = [contentStr boundingRectWithSize:constraint
  108. options:(NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading)
  109. attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:12],
  110. NSForegroundColorAttributeName : LCTextBlack
  111. }
  112. context:nil];
  113. CGFloat textH = rect.size.height ;
  114. bgViewHight+= rect.size.height+20;
  115. contTextView.frame = CGRectMake(MarginPadding, CGRectGetMaxX(titleL.frame)+20, KScreenWidth-MarginPadding*2, textH);
  116. NSString *contentStr1 = LCStr(word36);//@"守护收费:\n甜蜜守护20000钻/周\n心动守护52000钻/周\n唯一守护131400钻/周";
  117. //提示
  118. UITextView* hintTextView = [[UITextView alloc]init];
  119. [self addSubview:hintTextView];
  120. [hintTextView mas_makeConstraints:^(MASConstraintMaker *make) {
  121. make.left.mas_equalTo(MarginPadding);
  122. make.top.mas_equalTo(contTextView.mas_bottom).offset(20);
  123. make.right.mas_equalTo(-MarginPadding);
  124. make.height.mas_equalTo(120);
  125. }];
  126. [hintTextView setBackgroundColor:[UIColor clearColor]];
  127. hintTextView.scrollEnabled = NO;
  128. hintTextView.textColor = [UIColor whiteColor];
  129. hintTextView.font = [UIFont systemFontOfSize:14];
  130. hintTextView.text = contentStr1;
  131. hintTextView.editable = NO;
  132. CGSize constraint1 = CGSizeMake(hintTextView.contentSize.width, CGFLOAT_MAX);
  133. // CGSize size = [self.dyModel.content sizeWithFont:[UIFont systemFontOfSize:17] constrainedToSize:constraint lineBreakMode:NSLineBreakByWordWrapping];
  134. CGRect rect1 = [contentStr1 boundingRectWithSize:constraint1
  135. options:(NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading)
  136. attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:12],
  137. NSForegroundColorAttributeName : LCTextBlack
  138. }
  139. context:nil];
  140. CGFloat textH1 = rect1.size.height ;
  141. bgViewHight+=textH1+20;
  142. hintTextView.frame = CGRectMake(MarginPadding, CGRectGetMaxX(contTextView.frame)+20, KScreenWidth-MarginPadding*2, bgViewHight);
  143. bgView.frame = CGRectMake(15, 180, KScreenWidth-30, textH1);
  144. }
  145. -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
  146. [UIView animateWithDuration:0.0 animations:^{
  147. self.frame = CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight);
  148. } completion:^(BOOL finished) {
  149. [self removeFromSuperview];
  150. }];
  151. }
  152. @end