| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- //
- // NotifyMessageCell.m
- // MusicGradeExam
- //
- // Created by Kyle on 2020/7/15.
- // Copyright © 2020 DayaMusic. All rights reserved.
- //
- #import "NotifyMessageCell.h"
- @interface NotifyMessageCell ()
- @property (weak, nonatomic) IBOutlet UIView *redDot;
- @property (weak, nonatomic) IBOutlet UILabel *timeLabel;
- @property (weak, nonatomic) IBOutlet UILabel *topMessage;
- @property (weak, nonatomic) IBOutlet UILabel *descMessage;
- @property (nonatomic, strong) MessageListModel *model;
- @end
- @implementation NotifyMessageCell
- - (void)awakeFromNib {
- [super awakeFromNib];
- // Initialization code
- self.selectionStyle = UITableViewCellSelectionStyleNone;
- }
- - (void)configCellWithSource:(MessageListModel *)sourceModel {
- self.model = sourceModel;
- self.isRead = sourceModel.readStatus == 1 ? YES : NO;
- NSDateFormatter *dateFormatter=[[NSDateFormatter alloc] init];
- dateFormatter.timeZone = [NSTimeZone systemTimeZone];
- [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
- NSDate *messageDate = [dateFormatter dateFromString:sourceModel.modifyOn];
-
- [dateFormatter setDateFormat:@"yyyy-MM-dd"];
- NSDate *currentDate = [NSDate date];
- NSString *today = [dateFormatter stringFromDate:currentDate];
- NSString *messageDateStr = [dateFormatter stringFromDate:messageDate];
- NSString *dateStr = @"";
- if ([messageDateStr isEqualToString:today]) {
- [dateFormatter setDateFormat:@"HH:mm"];
- dateStr = [dateFormatter stringFromDate:messageDate];
- }
- else {
- [dateFormatter setDateFormat:@"MM-dd"];
- dateStr = [dateFormatter stringFromDate:messageDate];
- }
- self.timeLabel.text = [NSString returnNoNullStringWithString:dateStr];
- self.topMessage.text = [NSString returnNoNullStringWithString:sourceModel.title];
- NSString *messgage = [NSString returnNoNullStringWithString:sourceModel.content];
- NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
- [paragraphStyle setLineSpacing:4];//调整行间距
- NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:messgage attributes:@{NSParagraphStyleAttributeName:paragraphStyle,NSFontAttributeName:[UIFont systemFontOfSize:14.0f],NSForegroundColorAttributeName:HexRGB(0x808080)}];
- self.descMessage.attributedText = attrStr;
- }
- - (void)setIsRead:(BOOL)isRead {
- _isRead = isRead;
- self.redDot.hidden = isRead;
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- // Configure the view for the selected state
- }
- @end
|