VideoCollectionCell.m 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. //
  2. // VideoCollectionCell.m
  3. // YBVideo
  4. //
  5. // Created by YangBiao on 2017/9/5.
  6. // Copyright © 2017年 cat. All rights reserved.
  7. //
  8. #import "VideoCollectionCell.h"
  9. @implementation VideoCollectionCell
  10. {
  11. UILabel *label;
  12. UIImageView *imageV;
  13. UIView *view;
  14. }
  15. - (void)awakeFromNib {
  16. [super awakeFromNib];
  17. // Initialization code
  18. self.userAvatar.layer.masksToBounds = YES;
  19. self.userAvatar.layer.cornerRadius = self.userAvatar.width / 2;
  20. }
  21. - (void)setModel:(NearbyVideoModel *)model{
  22. _model = model;
  23. int videoCoin = [model.videoCoin intValue];
  24. _videoCoinBtn.hidden = YES;
  25. if (videoCoin > 0) {
  26. _videoCoinBtn.hidden = NO;
  27. [_videoCoinBtn setTitle:model.videoCoin forState:0];
  28. _videoImgType.hidden = NO;
  29. _videoImgType.image = [UIImage imageNamed:@"video_fufei"];
  30. }else if ([model.isgoods isEqual:@"1"]){
  31. _videoImgType.hidden = NO;
  32. _videoImgType.image = [UIImage imageNamed:@"video_gouwu"];
  33. }else{
  34. _videoImgType.hidden = YES;
  35. }
  36. [self.bgImageV sd_setImageWithURL:[NSURL URLWithString:model.videoImage]];
  37. self.titleLabel.text = model.videoTitle;
  38. [self.userAvatar sd_setImageWithURL:[NSURL URLWithString:model.userAvatar]];
  39. self.usernameLabel.text = model.userName;
  40. self.distanceLabel.text = model.distance;
  41. if ([self.isAtten isEqual:@"1"]) {
  42. self.distanceImage.image = [UIImage imageNamed:@"时间小图标"];
  43. self.distanceLabel.text = model.time;
  44. }
  45. if ([self.isList isEqual:@"1"]) {
  46. self.distanceImage.image = [UIImage imageNamed:@"评论小图标"];
  47. self.distanceLabel.text = model.commentNum;
  48. //添加右上角定位view
  49. if (view) {
  50. [view removeFromSuperview];
  51. view = nil;
  52. [label removeFromSuperview];
  53. label = nil;
  54. [imageV removeFromSuperview];
  55. imageV = nil;
  56. }
  57. NSString *str = model.city;
  58. if (str.length <= 0 || !str || [str isEqualToString:@"(null)"]) {
  59. return;
  60. }
  61. CGSize size = [str boundingRectWithSize:CGSizeMake(_window_width*0.65, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:10]} context:nil].size;
  62. view = [[UIView alloc] initWithFrame:CGRectMake(self.width - 20 - size.width - 9.5, 10, size.width + 16 + 9.5, 19)];
  63. view.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.2];
  64. view.layer.masksToBounds = YES;
  65. view.layer.cornerRadius = 9.5;
  66. view.hidden = YES;
  67. [self.contentView addSubview:view];
  68. imageV = [[UIImageView alloc] initWithFrame:CGRectMake(5, 3, 12, 12)];
  69. imageV.image = [UIImage imageNamed:@"定位小图标"];
  70. imageV.contentMode = UIViewContentModeScaleAspectFit;
  71. [view addSubview:imageV];
  72. label = [[UILabel alloc] initWithFrame:CGRectMake(16 + 2, 2, size.width, 15)];
  73. label.font = [UIFont systemFontOfSize:10];
  74. label.textColor = [UIColor whiteColor];
  75. label.text = str;
  76. [view addSubview:label];
  77. }
  78. if (_isTakeSameList) {
  79. _userAvatar.hidden = YES;
  80. _titleLabel.hidden = YES;
  81. _usernameLabel.hidden = YES;
  82. }
  83. }
  84. @end