YBUserListCell.m 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. //
  2. // YBUserListCell.m
  3. // YBVideo
  4. //
  5. // Created by YB007 on 2019/12/3.
  6. // Copyright © 2019 cat. All rights reserved.
  7. //
  8. #import "YBUserListCell.h"
  9. #import "SDWebImage/UIButton+WebCache.h"
  10. #import "UIImageView+WebCache.h"
  11. @implementation YBUserListCell
  12. - (void)awakeFromNib {
  13. [super awakeFromNib];
  14. // Initialization code
  15. }
  16. -(instancetype)initWithFrame:(CGRect)frame{
  17. self = [super initWithFrame:frame];
  18. if (self) {
  19. _imageV = [[UIImageView alloc]initWithFrame:CGRectMake(6.2,10.6,27.6,27.6)];
  20. _imageV.layer.masksToBounds = YES;
  21. _imageV.layer.cornerRadius = 13.8;
  22. [self.contentView addSubview:_imageV];
  23. _kuang = [[UIImageView alloc]initWithFrame:CGRectMake(0,0,40,40)];
  24. _kuang.center = self.contentView.center;
  25. [self.contentView addSubview:_kuang];
  26. _levelimage = [[UIImageView alloc]initWithFrame:CGRectMake(23,27,13,13)];
  27. _levelimage.layer.masksToBounds = YES;
  28. _levelimage.layer.cornerRadius = 6.5;
  29. _levelimage.contentMode = UIViewContentModeScaleAspectFit;
  30. [self.contentView addSubview:_levelimage];
  31. }
  32. return self;
  33. }
  34. -(void)setModel:(YBUserListModel *)model{
  35. _model = model;
  36. [_imageV sd_setImageWithURL:[NSURL URLWithString:_model.iconName] placeholderImage:[UIImage imageNamed:@"bg1"]];
  37. /*
  38. if ([_model.guard_type isEqual:@"0"]) {
  39. NSDictionary *levelDic = [common getUserLevelMessage:_model.level];
  40. [_levelimage sd_setImageWithURL:[NSURL URLWithString:minstr([levelDic valueForKey:@"thumb_mark"])]];
  41. }else if ([_model.guard_type isEqual:@"1"]){
  42. _levelimage.image = [UIImage imageNamed:@"chat_shou_month"];
  43. }else if ([_model.guard_type isEqual:@"2"]){
  44. _levelimage.image = [UIImage imageNamed:@"chat_shou_year"];
  45. }
  46. */
  47. if ([_model.guard_type isEqual:@"1"]){
  48. _levelimage.hidden = NO;
  49. _levelimage.image = [UIImage imageNamed:getImagename(@"chat_shou_month")];
  50. }else if ([_model.guard_type isEqual:@"2"]){
  51. _levelimage.hidden = NO;
  52. _levelimage.image = [UIImage imageNamed:getImagename(@"chat_shou_year")];
  53. }else {
  54. _levelimage.hidden = YES;
  55. }
  56. }
  57. +(YBUserListCell *)collectionview:(UICollectionView *)collectionview andIndexpath:(NSIndexPath *)indexpath{
  58. YBUserListCell *cell = [collectionview dequeueReusableCellWithReuseIdentifier:@"YBUserListCell" forIndexPath:indexpath];
  59. if (!cell) {
  60. cell = [[NSBundle mainBundle]loadNibNamed:@"YBUserListCell" owner:self options:nil].lastObject;
  61. }
  62. return cell;
  63. }
  64. @end