SmallVideoCell.m 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. //
  2. // SmallVideoCell.m
  3. // BuguLive
  4. //
  5. // Created by 丁凯 on 2017/8/17.
  6. // Copyright © 2017年 xfg. All rights reserved.
  7. #import "SmallVideoCell.h"
  8. #import "SmallVideoListModel.h"
  9. @implementation SmallVideoCell
  10. - (void)awakeFromNib
  11. {
  12. [super awakeFromNib];
  13. self.smallImgView.layer.cornerRadius = 25*kScaleWidth/2;
  14. self.bottomView.layer.cornerRadius = self.bottomView.height/2;
  15. self.smallImgView.layer.masksToBounds = YES;
  16. self.bottomView.layer.masksToBounds = YES;
  17. self.bottomView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.2];
  18. self.bigImgView.layer.cornerRadius = 5;
  19. self.bigImgView.layer.masksToBounds = YES;
  20. self.isCheckView.layer.cornerRadius = 5;
  21. self.isCheckView.layer.masksToBounds = YES;
  22. self.smallImgView.hidden = YES;
  23. self.isCheckView.hidden = YES;
  24. self.watchNum.imagePosition = QMUIButtonImagePositionLeft;
  25. self.watchNum.spacingBetweenImageAndTitle = 2;
  26. self.headImg.layer.cornerRadius = 22 / 2;
  27. self.headImg.layer.masksToBounds = YES;
  28. // self.nickNameBtn.imagePosition = QMUIButtonImagePositionLeft;
  29. // self.nickNameBtn.spacingBetweenImageAndTitle = 2;
  30. }
  31. - (void)creatCellWithModel:(SmallVideoListModel *)model andRow:(int)row
  32. {
  33. if (![BGUtils isBlankString:model.is_audit]) {
  34. self.isCheckView.hidden = [model.is_audit isEqualToString:@"1"];
  35. }
  36. [self.bigImgView sd_setImageWithURL:[NSURL URLWithString:model.photo_image] placeholderImage:kDefaultPreloadImgSquare];
  37. [self.smallImgView sd_setImageWithURL:[NSURL URLWithString:model.head_image] placeholderImage:kDefaultPreloadHeadImg];
  38. self.nameLabel.text = model.nick_name;
  39. // model.nick_name;
  40. NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:model.video_count];
  41. [attr setAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:11.0]} range:NSMakeRange(0, model.video_count.length)];
  42. CGFloat width =[model.video_count sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:11]}].width;
  43. self.bottomViewConstraintW.constant = width + 38;
  44. self.numLbale.attributedText = attr;
  45. // [self.nickNameBtn setTitle:model.nick_name forState:UIControlStateNormal];
  46. [self.headImg sd_setImageWithURL:[NSURL URLWithString:model.head_image] placeholderImage:nil];
  47. // WeakSelf
  48. // [self.nickNameBtn sd_setImageWithURL:[NSURL URLWithString:model.head_image] forState:UIControlStateNormal completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
  49. //// CGSize size = image.size;
  50. //// self.widthConstraint.constant = size.width / 3;
  51. //// self.heightConstraint.constant = size.height / 3;
  52. // image = [weakSelf scaleImage:image scaleToSize:CGSizeMake(kRealValue(22), kRealValue(22))];
  53. // [weakSelf.nickNameBtn setImage:image forState:UIControlStateNormal];
  54. // }];
  55. self.titleL.text = model.content;
  56. [self.watchNum setTitle:model.video_count forState:UIControlStateNormal];
  57. }
  58. - (UIImage*)scaleImage:(UIImage *)image scaleToSize:(CGSize)size{
  59. UIGraphicsBeginImageContext(size);
  60. [image drawInRect:CGRectMake(0, 0, size.width, size.height)];
  61. UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext();
  62. UIGraphicsEndImageContext();
  63. return scaledImage;
  64. }
  65. @end