MsgTopPubCell.m 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. //
  2. // MsgTopPubCell.m
  3. // YBVideo
  4. //
  5. // Created by YunBao on 2018/7/24.
  6. // Copyright © 2018年 cat. All rights reserved.
  7. //
  8. #import "MsgTopPubCell.h"
  9. @implementation MsgTopPubCell
  10. - (void)awakeFromNib {
  11. [super awakeFromNib];
  12. // Initialization code
  13. _iconBtn.layer.masksToBounds = YES;
  14. _iconBtn.layer.cornerRadius = _iconBtn.width/2;
  15. _iconBtn.imageView.clipsToBounds = YES;
  16. [_iconBtn.imageView setContentMode:UIViewContentModeScaleAspectFill];
  17. _iconBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentFill;
  18. _iconBtn.contentVerticalAlignment = UIControlContentVerticalAlignmentFill;
  19. [_coverBtn.imageView setContentMode:UIViewContentModeScaleAspectFill];
  20. _coverBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentFill;
  21. _coverBtn.contentVerticalAlignment = UIControlContentVerticalAlignmentFill;
  22. }
  23. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  24. [super setSelected:selected animated:animated];
  25. }
  26. +(MsgTopPubCell*)cellWithTab:(UITableView *)tableView andIndexPath:(NSIndexPath*)indexPath {
  27. MsgTopPubCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MsgTopPubCell"];
  28. if (!cell) {
  29. cell = [[[NSBundle mainBundle]loadNibNamed:@"MsgTopPubCell" owner:nil options:nil]objectAtIndex:0];
  30. }
  31. return cell;
  32. }
  33. - (void)setModel:(MsgTopPubModel *)model {
  34. _model = model;
  35. [_iconBtn sd_setImageWithURL:[NSURL URLWithString:_model.iconStr] forState:0];
  36. [_coverBtn sd_setImageWithURL:[NSURL URLWithString:_model.coverStr] forState:0];
  37. _timeL.text = _model.timeStr;
  38. if ([_model.pageVC isEqual:@"赞"]) {
  39. if ([_model.typeStr isEqual:@"0"]) {
  40. _contentL.text = [NSString stringWithFormat:@"%@ %@",_model.unameStr,YZMsg(@"赞了您的评论")];
  41. }else{
  42. _contentL.text = [NSString stringWithFormat:@"%@ %@",_model.unameStr,YZMsg(@"赞了您的作品")];
  43. }
  44. NSMutableAttributedString *attStr=[[NSMutableAttributedString alloc]initWithString:_contentL.text];
  45. [attStr addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(0, _model.unameStr.length)];
  46. _contentL.attributedText = attStr;
  47. }else if ([_model.pageVC isEqual:@"@我的"]){
  48. NSString *video_title;
  49. if (_model.videoTitleStr.length <= 0) {
  50. video_title = YZMsg(@"无标题");
  51. }else if(_model.videoTitleStr.length <5){
  52. video_title = _model.videoTitleStr;
  53. }else {
  54. video_title = [_model.videoTitleStr stringByReplacingCharactersInRange:NSMakeRange(5, _model.videoTitleStr.length-5) withString:@"..."];
  55. }
  56. if ([_model.typeStr isEqual:@"1"]) {
  57. //1-上热门@
  58. _contentL.text = [NSString stringWithFormat:@"%@ %@",_model.unameStr,YZMsg(@"将您的作品投放至热门,快去看看吧")];
  59. }else {
  60. //0-评论@
  61. _contentL.text = [NSString stringWithFormat:@"%@ %@ %@ %@",_model.unameStr,YZMsg(@"在"),video_title,YZMsg(@"的评论中@了你")];
  62. }
  63. NSMutableAttributedString *attStr=[[NSMutableAttributedString alloc]initWithString:_contentL.text];
  64. [attStr addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(0, _model.unameStr.length)];
  65. _contentL.attributedText = attStr;
  66. }else{//评论
  67. _contentL.textColor = [UIColor blackColor];
  68. NSString *showDes = YZMsg(@"评论了您的作品");
  69. _contentL.text = [NSString stringWithFormat:@"%@ %@\n%@",_model.unameStr,showDes,_model.commentConStr];
  70. NSMutableAttributedString *attStr=[[NSMutableAttributedString alloc]initWithString:_contentL.text];
  71. [attStr addAttribute:NSForegroundColorAttributeName value:UIColor.grayColor range:NSMakeRange(_model.unameStr.length,showDes.length+2)];
  72. _contentL.attributedText = attStr;
  73. }
  74. }
  75. - (IBAction)clickIconBtn:(UIButton *)sender {
  76. if ([self.delegatge respondsToSelector:@selector(iconClickUid:)]) {
  77. [self.delegatge iconClickUid:_model.uidStr];
  78. }
  79. }
  80. - (IBAction)clickCoverBtn:(UIButton *)sender {
  81. if ([self.delegatge respondsToSelector:@selector(coverClickVideoid:)]) {
  82. [self.delegatge coverClickVideoid:_model.videoidStr];
  83. }
  84. }
  85. @end