NIMSessionTimestampCell.m 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // NTESSessionTipCell.m
  3. // NIMDemo
  4. //
  5. // Created by ght on 15-1-28.
  6. // Copyright (c) 2015年 Netease. All rights reserved.
  7. //
  8. #import "NIMSessionTimestampCell.h"
  9. #import "NIMCellConfig.h"
  10. #import "UIView+NIM.h"
  11. #import "NIMTimestampModel.h"
  12. #import "NIMKitUtil.h"
  13. #import "UIImage+NIMKit.h"
  14. #import "NIMKit.h"
  15. @interface NIMSessionTimestampCell()
  16. @property (nonatomic,strong) NIMTimestampModel *model;
  17. @end
  18. @implementation NIMSessionTimestampCell
  19. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  20. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  21. if (self) {
  22. self.backgroundColor = [NIMKit sharedKit].config.cellBackgroundColor;
  23. self.selectionStyle = UITableViewCellSelectionStyleNone;
  24. // _timeBGView = [[UIImageView alloc] initWithFrame:CGRectZero];
  25. // [self addSubview:_timeBGView];
  26. _timeLabel = [[UILabel alloc] initWithFrame:CGRectZero];
  27. _timeLabel.font = [UIFont systemFontOfSize:11.f];
  28. _timeLabel.textColor = LZA3AABEColor;
  29. [self addSubview:_timeLabel];
  30. // [_timeBGView setImage:[[UIImage nim_imageInKit:@"icon_session_time_bg"] resizableImageWithCapInsets:UIEdgeInsetsMake(8,20,8,20) resizingMode:UIImageResizingModeStretch]];
  31. }
  32. return self;
  33. }
  34. - (void)layoutSubviews
  35. {
  36. [super layoutSubviews];
  37. [_timeLabel sizeToFit];
  38. _timeLabel.center = CGPointMake(self.nim_centerX, 20);
  39. // _timeBGView.frame = CGRectMake(_timeLabel.nim_left - 7, _timeLabel.nim_top - 2, _timeLabel.nim_width + 14, _timeLabel.nim_height + 4);
  40. }
  41. - (void)refreshData:(NIMTimestampModel *)data{
  42. self.model = data;
  43. if([self checkData]){
  44. NIMTimestampModel *model = (NIMTimestampModel *)data;
  45. [_timeLabel setText:[NIMKitUtil showTime:model.messageTime showDetail:YES]];
  46. }
  47. }
  48. - (BOOL)checkData{
  49. return [self.model isKindOfClass:[NIMTimestampModel class]];
  50. }
  51. @end