YBLiveEndView.m 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. //
  2. // YBLiveEndView.m
  3. // YBVideo
  4. //
  5. // Created by YB007 on 2019/11/30.
  6. // Copyright © 2019 cat. All rights reserved.
  7. //
  8. #import "YBLiveEndView.h"
  9. @interface YBLiveEndView()
  10. @property(nonatomic,strong)UIImageView *bgIV;
  11. @property(nonatomic,strong)UIImageView *avatarIV;
  12. @property(nonatomic,strong)UILabel *nameL;
  13. @property(nonatomic,strong)UILabel *liveTimeL;
  14. @property(nonatomic,strong)UILabel *liveVotesL;
  15. @property(nonatomic,strong)UILabel *liveNumL;
  16. @end
  17. @implementation YBLiveEndView
  18. - (instancetype)initWithFrame:(CGRect)frame {
  19. self = [super initWithFrame:frame];
  20. if (self) {
  21. [self createUI];
  22. }
  23. return self;
  24. }
  25. -(void)createUI {
  26. _bgIV = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, _window_width, _window_height)];
  27. _bgIV.userInteractionEnabled = YES;
  28. UIBlurEffect *blur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
  29. UIVisualEffectView *effectview = [[UIVisualEffectView alloc] initWithEffect:blur];
  30. effectview.frame = CGRectMake(0, 0,_window_width,_window_height);
  31. [_bgIV addSubview:effectview];
  32. UILabel *labell= [[UILabel alloc]initWithFrame:CGRectMake(0,24+statusbarHeight, _window_width, _window_height*0.17)];
  33. labell.textColor = Pink_Cor;
  34. labell.text = YZMsg(@"直播已结束");
  35. labell.textAlignment = NSTextAlignmentCenter;
  36. labell.font = [UIFont fontWithName:@"Helvetica-Bold" size:20];
  37. [_bgIV addSubview:labell];
  38. UIView *backView = [[UIView alloc]initWithFrame:CGRectMake(_window_width*0.1, labell.bottom+50, _window_width*0.8, _window_width*0.8*8/13)];
  39. backView.backgroundColor = RGB_COLOR(@"#000000", 0.2);
  40. backView.layer.cornerRadius = 5.0;
  41. backView.layer.masksToBounds = YES;
  42. [_bgIV addSubview:backView];
  43. _avatarIV = [[UIImageView alloc]initWithFrame:CGRectMake(_window_width/2-50, labell.bottom, 100, 100)];
  44. _avatarIV.layer.masksToBounds = YES;
  45. _avatarIV.layer.cornerRadius = 50;
  46. [_bgIV addSubview:_avatarIV];
  47. _nameL= [[UILabel alloc]initWithFrame:CGRectMake(0,50, backView.width, backView.height*0.55-50)];
  48. _nameL.textColor = [UIColor whiteColor];
  49. _nameL.text = [Config getOwnNicename];
  50. _nameL.textAlignment = NSTextAlignmentCenter;
  51. _nameL.font = [UIFont fontWithName:@"Helvetica-Bold" size:18];
  52. [backView addSubview:_nameL];
  53. [PublicObj lineViewWithFrame:CGRectMake(10, _nameL.bottom, backView.width-20, 1) andColor:RGB_COLOR(@"#585452", 1) andView:backView];
  54. NSArray *labelArray = @[YZMsg(@"直播时长"),[NSString stringWithFormat:@"%@%@",YZMsg(@"收获"),[common name_votes]],YZMsg(@"观看人数")];
  55. if (![lagType isEqual:ZH_CN]) {
  56. labelArray = @[YZMsg(@"直播时长"),@"Income",YZMsg(@"观看人数")];
  57. }
  58. for (int i = 0; i < labelArray.count; i++) {
  59. UILabel *topLabel = [[UILabel alloc]initWithFrame:CGRectMake(i*backView.width/3, _nameL.bottom, backView.width/3, backView.height/4)];
  60. topLabel.font = [UIFont boldSystemFontOfSize:18];
  61. topLabel.textColor = [UIColor whiteColor];
  62. topLabel.textAlignment = NSTextAlignmentCenter;
  63. if (i == 0) {
  64. _liveTimeL = topLabel;
  65. }
  66. if (i == 1) {
  67. _liveVotesL = topLabel;
  68. }
  69. if (i == 2) {
  70. _liveNumL = topLabel;
  71. }
  72. [backView addSubview:topLabel];
  73. UILabel *footLabel = [[UILabel alloc]initWithFrame:CGRectMake(topLabel.left, topLabel.bottom, topLabel.width, 14)];
  74. footLabel.font = [UIFont systemFontOfSize:13];
  75. footLabel.textColor = RGB_COLOR(@"#cacbcc", 1);
  76. footLabel.textAlignment = NSTextAlignmentCenter;
  77. footLabel.text = labelArray[i];
  78. [backView addSubview:footLabel];
  79. }
  80. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  81. button.frame = CGRectMake(_window_width*0.1,_window_height *0.75, _window_width*0.8,50);
  82. [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  83. [button addTarget:self action:@selector(docancle) forControlEvents:UIControlEventTouchUpInside];
  84. button.backgroundColor = Pink_Cor;
  85. [button setTitle:YZMsg(@"返回首页") forState:0];
  86. button.titleLabel.font = [UIFont systemFontOfSize:15];
  87. button.layer.cornerRadius = 25;
  88. button.layer.masksToBounds =YES;
  89. [_bgIV addSubview:button];
  90. [self addSubview:_bgIV];
  91. }
  92. -(void)docancle {
  93. if (self.liveEndEvent) {
  94. self.liveEndEvent();
  95. }
  96. }
  97. -(void)updateData:(NSDictionary *)dic {
  98. [_bgIV sd_setImageWithURL:[NSURL URLWithString:minstr([dic valueForKey:@"hostAvatar"])]];
  99. [_avatarIV sd_setImageWithURL:[NSURL URLWithString:minstr([dic valueForKey:@"hostAvatar"])] placeholderImage:[UIImage imageNamed:@"bg1"]];
  100. _nameL.text = minstr([dic valueForKey:@"hostName"]);
  101. _liveTimeL.text = minstr([dic valueForKey:@"length"]);
  102. _liveVotesL.text = minstr([dic valueForKey:@"votes"]);
  103. _liveNumL.text = minstr([dic valueForKey:@"nums"]);
  104. }
  105. @end