FriendsListCell.m 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. //
  2. // FriendsListCell.m
  3. // Unity-iPhone
  4. //
  5. // Created by duowan123 on 2022/9/2.
  6. //
  7. #import "FriendsListCell.h"
  8. #define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
  9. #define SCALEoefficient(num) (SCREEN_WIDTH/667.0)*(num)
  10. @interface FriendsListCell ()<UIGestureRecognizerDelegate>
  11. @property (weak, nonatomic) IBOutlet UIImageView *imageView;
  12. @property (weak, nonatomic) IBOutlet UILabel *titleStr;
  13. @property (weak, nonatomic) IBOutlet UILabel *statusLabel;
  14. @end
  15. @implementation FriendsListCell
  16. - (void)awakeFromNib{
  17. [super awakeFromNib];
  18. self.covierView.backgroundColor = [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0];
  19. self.covierView.layer.shadowColor = [UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:0.16].CGColor;
  20. self.covierView.layer.shadowOffset = CGSizeMake(0,3);
  21. self.covierView.layer.shadowRadius = 6;
  22. self.covierView.layer.shadowOpacity = 1;
  23. self.covierView.layer.cornerRadius = 10;
  24. self.imageView.layer.masksToBounds = YES;
  25. self.imageView.layer.cornerRadius = 50;
  26. self.titleStr.font = [UIFont systemFontOfSize: SCALEoefficient(20)];
  27. self.statusLabel.font = [UIFont systemFontOfSize: SCALEoefficient(15)];
  28. //cell添加点击事件
  29. UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(myTableViewClick:)];
  30. [self.contentView addGestureRecognizer:tapGesture];
  31. }
  32. #pragma mark - 点击事件
  33. - (void)myTableViewClick:(UIGestureRecognizer *)gestureRecognizer{
  34. if (self.tapGestureBlock){
  35. self.tapGestureBlock(self.model.numberId);
  36. }
  37. }
  38. /**
  39. 加载数据
  40. @param model ShoesPeripheralMolde
  41. */
  42. -(void)setCarouselCellModel:(UserFriendsModel *)model{
  43. if (self.model!=model){
  44. self.model = model;
  45. }
  46. NSLog(@"model.nickname = %@",model.nickname);
  47. if (model.nickname!=nil){
  48. self.titleStr.text = model.nickname;
  49. self.imageView.image= [UIImage imageWithData:[NSData dataWithContentsOfURL: [NSURL URLWithString:model.avatar]]];
  50. }
  51. if ([model.status isEqualToString:@"1"]){
  52. self.stateLable.text = @"·在线";
  53. self.stateLable.textColor = [UIColor greenColor];
  54. }else{
  55. self.stateLable.text = @"·离线";
  56. self.stateLable.textColor = [UIColor grayColor];
  57. }
  58. }
  59. //更新状态
  60. -(void)setCusSelected:(BOOL)cusSelected{
  61. if (cusSelected == YES){
  62. NSLog(@"cusSelected %ld ",(long)self.model.trans_id);
  63. self.covierView.layer.masksToBounds = YES;
  64. self.covierView.layer.borderColor = [UIColor colorWithRed:255/255.0 green:196/255.0 blue:0/255.0 alpha:1.0].CGColor;
  65. self.covierView.layer.borderWidth = 3;
  66. self.covierView.backgroundColor = [UIColor colorWithRed:255/255.0 green:245/255.0 blue:210/255.0 alpha:1.0];
  67. self.covierView.layer.cornerRadius = 15;
  68. }else{
  69. self.covierView.layer.masksToBounds = YES;
  70. self.covierView.layer.borderColor = [UIColor whiteColor].CGColor;
  71. self.covierView.layer.borderWidth = 3;
  72. self.covierView.backgroundColor = [UIColor whiteColor];
  73. self.covierView.layer.cornerRadius = 15;
  74. }
  75. }
  76. @end