BGVideoMirrorCell.m 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. //
  2. // BGVideoMirrorCell.m
  3. // BuguLive
  4. //
  5. // Created by fanwe2014 on 2017/3/24.
  6. // Copyright © 2017年 xfg. All rights reserved.
  7. //
  8. #import "BGVideoMirrorCell.h"
  9. #import "TTTAttributedLabel.h"
  10. @implementation BGVideoMirrorCell
  11. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  12. {
  13. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
  14. {
  15. self.contentView.bounds = [UIScreen mainScreen].bounds;
  16. [self creatMainView];
  17. }
  18. return self ;
  19. }
  20. - (void)creatMainView
  21. {
  22. self.headImgView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 40, 40)];
  23. self.headImgView.userInteractionEnabled = YES;
  24. self.headImgView.layer.cornerRadius = 20;
  25. self.headImgView.layer.masksToBounds = YES;
  26. self.headImgView.image = kDefaultPreloadHeadImg;
  27. self.headImgView.contentMode = UIViewContentModeScaleAspectFit;
  28. self.headImgView.tag = 2;
  29. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imgViewTap:)];
  30. [self.headImgView addGestureRecognizer:tap];
  31. [self addSubview:self.headImgView];
  32. self.iconImgView = [[UIImageView alloc] initWithFrame:CGRectMake(40, 40, 10, 10)];
  33. [self addSubview:self.iconImgView];
  34. self.zanLabel = [[UILabel alloc]initWithFrame:CGRectMake(kScreenW-50, 10, 40, 20)];
  35. self.zanLabel.textColor = kAppGrayColor3;
  36. self.zanLabel.font = [UIFont systemFontOfSize:11];
  37. [self addSubview:self.zanLabel];
  38. self.zanImgView = [[UIImageView alloc]initWithFrame:CGRectMake(kScreenW-64, 14, 12, 11)];
  39. self.zanImgView.image = [UIImage imageNamed:@"fw_personCenter_noZan"];
  40. [self addSubview:self.zanImgView];
  41. self.ZanBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  42. self.ZanBtn.frame =CGRectMake(kScreenW-65, 10, 65, 22);
  43. self.ZanBtn.backgroundColor = kClearColor;
  44. [self.ZanBtn addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
  45. [self addSubview:self.ZanBtn];
  46. self.videoLabel = [[UILabel alloc]initWithFrame:CGRectMake(kScreenW-108, 10, 40, 20)];
  47. self.videoLabel.textColor = RGB(153, 153, 153);
  48. self.videoLabel.font = [UIFont systemFontOfSize:11];
  49. [self addSubview:self.videoLabel];
  50. self.videoImgView = [[UIImageView alloc]initWithFrame:CGRectMake(kScreenW-122, 14, 12, 11)];
  51. self.videoImgView.image = [UIImage imageNamed:@"fw_personCenter_playNum"];
  52. [self addSubview:self.videoImgView];
  53. self.videoBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  54. self.videoBtn.frame =CGRectMake(kScreenW-116, 10, 65, 22);
  55. self.videoBtn.tag = 1;
  56. self.videoBtn.backgroundColor = kClearColor;
  57. [self.videoBtn addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
  58. [self addSubview:self.videoBtn];
  59. self.nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(60, 10, kScreenW-185, 20)];
  60. self.nameLabel.textColor = kAppGrayColor1;
  61. self.nameLabel.font = [UIFont systemFontOfSize:14];
  62. self.nameLabel.lineBreakMode = NSLineBreakByTruncatingTail;
  63. [self addSubview:self.nameLabel];
  64. self.abstractLabel = [[TTTAttributedLabel alloc]initWithFrame:CGRectMake(70,CGRectGetMaxY(self.nameLabel.frame)+5, kScreenW-70, 0)];
  65. self.abstractLabel.textColor = RGB(153, 153, 153);
  66. self.abstractLabel.textAlignment = NSTextAlignmentLeft;
  67. self.abstractLabel.font = [UIFont systemFontOfSize:11];
  68. self.abstractLabel.numberOfLines = 0;
  69. [self addSubview:self.abstractLabel];
  70. self.lineView = [[UIView alloc]init];
  71. self.lineView.backgroundColor = kAppSpaceColor2;
  72. [self addSubview:self.lineView];
  73. }
  74. - (CGFloat)creatCellWithModel:(PersonCenterListModel *)model andRow:(int)row isVideo:(BOOL)isVideo
  75. {
  76. [self.headImgView sd_setImageWithURL:[NSURL URLWithString:model.head_image] placeholderImage:kDefaultPreloadHeadImg];
  77. self.headImgView.tag = row;
  78. if ([model.is_authentication intValue] != 2)
  79. {
  80. self.iconImgView.hidden = YES;
  81. }
  82. [self.iconImgView sd_setImageWithURL:[NSURL URLWithString:model.v_icon] placeholderImage:kDefaultPreloadHeadImg];
  83. NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:model.nick_name];
  84. self.nameLabel.attributedText = attr;
  85. NSString *nameString;
  86. if (isVideo)
  87. {
  88. nameString = [NSString stringWithFormat:ASLocalizedString(@"视频简介:%@"),model.content];
  89. }else
  90. {
  91. self.videoLabel.hidden = YES;
  92. self.videoBtn.hidden = YES;
  93. self.videoImgView.hidden = YES;
  94. nameString = [NSString stringWithFormat:ASLocalizedString(@"写真简介:%@"),model.content];
  95. }
  96. if (model.has_digg ==1)
  97. {
  98. self.zanImgView.image = [UIImage imageNamed:@"fw_personCenter_zan"];
  99. self.zanLabel.textColor = kAppGrayColor1;
  100. }
  101. self.zanLabel.text = model.digg_count;
  102. self.videoLabel.text = model.video_count;
  103. NSMutableAttributedString *attr1 = [[NSMutableAttributedString alloc] initWithString:nameString];
  104. self.abstractLabel.attributedText = attr1;
  105. NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
  106. paragraphStyle.maximumLineHeight = 18.0f;
  107. paragraphStyle.minimumLineHeight = 16.0f;
  108. paragraphStyle.firstLineHeadIndent = 0.0f;
  109. paragraphStyle.lineSpacing = 6.0f;
  110. paragraphStyle.firstLineHeadIndent = 0.0f;
  111. paragraphStyle.headIndent = 0.0f;
  112. paragraphStyle.alignment = NSTextAlignmentLeft;
  113. UIFont *font = [UIFont systemFontOfSize:11];
  114. NSDictionary *attributes = @{NSFontAttributeName:font, NSParagraphStyleAttributeName:paragraphStyle,NSForegroundColorAttributeName:RGB(153, 153, 153)};
  115. self.abstractLabel.attributedText = [[NSAttributedString alloc]initWithString:nameString attributes:attributes];
  116. CGSize size = CGSizeMake(self.abstractLabel.frame.size.width, 1000.0f);
  117. CGFloat height = [self.abstractLabel sizeThatFits:size].height;
  118. self.abstractLabel.verticalAlignment = TTTAttributedLabelVerticalAlignmentTop;
  119. if (height < 21)
  120. {
  121. height = 21;
  122. }
  123. self.abstractLabel.frame = CGRectMake(60, CGRectGetMaxY(self.nameLabel.frame)+5, kScreenW-70, height);
  124. self.lineView.frame = CGRectMake(10, CGRectGetMaxY(self.abstractLabel.frame)+12, kScreenW-10, 1);
  125. return self.lineView.frame.size.height+self.lineView.frame.origin.y;
  126. }
  127. - (void)buttonClick:(UIButton *)sender
  128. {
  129. if (self.ZVDelegate && [self.ZVDelegate respondsToSelector:@selector(zanOrVideoClickWithTag:)])
  130. {
  131. [self.ZVDelegate zanOrVideoClickWithTag:(int)sender.tag];
  132. }
  133. }
  134. - (void)imgViewTap:(UITapGestureRecognizer *)tap
  135. {
  136. if (self.ZVDelegate && [self.ZVDelegate respondsToSelector:@selector(zanOrVideoClickWithTag:)])
  137. {
  138. [self.ZVDelegate zanOrVideoClickWithTag:2];
  139. }
  140. }
  141. @end