NotifyMessageCell.m 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //
  2. // NotifyMessageCell.m
  3. // MusicGradeExam
  4. //
  5. // Created by Kyle on 2020/7/15.
  6. // Copyright © 2020 DayaMusic. All rights reserved.
  7. //
  8. #import "NotifyMessageCell.h"
  9. @interface NotifyMessageCell ()
  10. @property (weak, nonatomic) IBOutlet UIView *redDot;
  11. @property (weak, nonatomic) IBOutlet UILabel *timeLabel;
  12. @property (weak, nonatomic) IBOutlet UILabel *topMessage;
  13. @property (weak, nonatomic) IBOutlet UILabel *descMessage;
  14. @property (nonatomic, strong) MessageListModel *model;
  15. @end
  16. @implementation NotifyMessageCell
  17. - (void)awakeFromNib {
  18. [super awakeFromNib];
  19. // Initialization code
  20. self.selectionStyle = UITableViewCellSelectionStyleNone;
  21. }
  22. - (void)configCellWithSource:(MessageListModel *)sourceModel {
  23. self.model = sourceModel;
  24. self.isRead = sourceModel.readStatus == 1 ? YES : NO;
  25. NSDateFormatter *dateFormatter=[[NSDateFormatter alloc] init];
  26. dateFormatter.timeZone = [NSTimeZone systemTimeZone];
  27. [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
  28. NSDate *messageDate = [dateFormatter dateFromString:sourceModel.createOn];
  29. [dateFormatter setDateFormat:@"MM-dd"];
  30. NSString *dateStr = [dateFormatter stringFromDate:messageDate];
  31. self.timeLabel.text = [NSString returnNoNullStringWithString:dateStr];
  32. self.topMessage.text = [NSString returnNoNullStringWithString:sourceModel.title];
  33. }
  34. - (void)setIsRead:(BOOL)isRead {
  35. _isRead = isRead;
  36. self.redDot.hidden = isRead;
  37. }
  38. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  39. [super setSelected:selected animated:animated];
  40. // Configure the view for the selected state
  41. }
  42. @end