92 lines
2.4 KiB
Objective-C
92 lines
2.4 KiB
Objective-C
//
|
|
// MessageContentMonentsAutoView.m
|
|
// YUMI
|
|
//
|
|
// Created by YUMI on 2022/8/26.
|
|
//
|
|
|
|
#import "MessageContentMonentsAutoView.h"
|
|
///Third
|
|
#import <Masonry/Masonry.h>
|
|
///Tool
|
|
#import "NSObject+MJExtension.h"
|
|
#import "DJDKMIMOMColor.h"
|
|
///Model
|
|
#import "MessageMonentsAutoModel.h"
|
|
@interface MessageContentMonentsAutoView ()
|
|
|
|
@property (nonatomic, strong) UILabel *titleLabel; // 标题
|
|
@property (nonatomic, strong) UILabel *timeLabel; // 时间
|
|
@property (nonatomic, strong) UILabel *messageLabel; // 内容
|
|
@end
|
|
|
|
@implementation MessageContentMonentsAutoView
|
|
|
|
- (void)initSubViews {
|
|
[super initSubViews];
|
|
[self addSubview:self.backView];
|
|
|
|
[self.backView addSubview:self.titleLabel];
|
|
[self.backView addSubview:self.timeLabel];
|
|
[self.backView addSubview:self.messageLabel];
|
|
}
|
|
|
|
- (void)initSubViewConstraints {
|
|
[super initSubViewConstraints];
|
|
[self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.size.mas_equalTo(CGSizeMake(250, 120));
|
|
}];
|
|
|
|
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.leading.mas_equalTo(14.5);
|
|
make.top.mas_equalTo(10);
|
|
}];
|
|
|
|
[self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.trailing.mas_equalTo(-14.5);
|
|
make.centerY.mas_equalTo(self.titleLabel);
|
|
}];
|
|
|
|
[self.messageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.leading.trailing.mas_equalTo(self).inset(14.5);
|
|
make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(12.5);
|
|
}];
|
|
}
|
|
|
|
- (void)render:(MessageBaseModel *)message {
|
|
MessageMonentsAutoModel *obj = (MessageMonentsAutoModel *)message;
|
|
self.titleLabel.text = obj.title;
|
|
self.timeLabel.text = obj.time;
|
|
self.messageLabel.attributedText = obj.attributedText;
|
|
}
|
|
|
|
- (UILabel *)titleLabel {
|
|
if (!_titleLabel) {
|
|
_titleLabel = [[UILabel alloc] init];
|
|
_titleLabel.textColor = UIColorFromRGB(0x333333);
|
|
_titleLabel.font = [UIFont boldSystemFontOfSize:15];
|
|
}
|
|
return _titleLabel;
|
|
}
|
|
|
|
- (UILabel *)timeLabel {
|
|
if (!_timeLabel) {
|
|
_timeLabel = [[UILabel alloc] init];
|
|
_timeLabel.textColor = UIColorFromRGB(0x999999);
|
|
_timeLabel.font = [UIFont systemFontOfSize:12];
|
|
_timeLabel.textAlignment = NSTextAlignmentRight;
|
|
}
|
|
return _timeLabel;
|
|
}
|
|
|
|
- (UILabel *)messageLabel {
|
|
if (!_messageLabel) {
|
|
_messageLabel = [[UILabel alloc] init];
|
|
_messageLabel.textColor = UIColorFromRGB(0x333333);
|
|
_messageLabel.font = [UIFont systemFontOfSize:14];
|
|
_messageLabel.numberOfLines = 0;
|
|
}
|
|
return _messageLabel;
|
|
}
|
|
@end
|