分类移动文件
This commit is contained in:
67
keyBoard/Class/AiTalk/V/Chat/KBChatUserMessageCell.m
Normal file
67
keyBoard/Class/AiTalk/V/Chat/KBChatUserMessageCell.m
Normal file
@@ -0,0 +1,67 @@
|
||||
//
|
||||
// KBChatUserMessageCell.m
|
||||
// keyBoard
|
||||
//
|
||||
// Created by Kiro on 2026/1/23.
|
||||
//
|
||||
|
||||
#import "KBChatUserMessageCell.h"
|
||||
#import "KBAiChatMessage.h"
|
||||
#import <Masonry/Masonry.h>
|
||||
|
||||
@interface KBChatUserMessageCell ()
|
||||
|
||||
@property (nonatomic, strong) UIView *bubbleView;
|
||||
@property (nonatomic, strong) UILabel *messageLabel;
|
||||
|
||||
@end
|
||||
|
||||
@implementation KBChatUserMessageCell
|
||||
|
||||
- (instancetype)initWithStyle:(UITableViewCellStyle)style
|
||||
reuseIdentifier:(NSString *)reuseIdentifier {
|
||||
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
|
||||
if (self) {
|
||||
self.backgroundColor = [UIColor clearColor];
|
||||
self.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
[self setupUI];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setupUI {
|
||||
// 气泡视图
|
||||
self.bubbleView = [[UIView alloc] init];
|
||||
self.bubbleView.backgroundColor = [UIColor colorWithRed:0.94 green:0.94 blue:0.94 alpha:1.0];
|
||||
self.bubbleView.layer.cornerRadius = 16;
|
||||
self.bubbleView.layer.masksToBounds = YES;
|
||||
[self.contentView addSubview:self.bubbleView];
|
||||
|
||||
// 消息标签
|
||||
self.messageLabel = [[UILabel alloc] init];
|
||||
self.messageLabel.numberOfLines = 0;
|
||||
self.messageLabel.font = [UIFont systemFontOfSize:16];
|
||||
self.messageLabel.textColor = [UIColor blackColor];
|
||||
[self.bubbleView addSubview:self.messageLabel];
|
||||
|
||||
// 布局约束
|
||||
[self.bubbleView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.contentView).offset(4);
|
||||
make.bottom.equalTo(self.contentView).offset(-4);
|
||||
make.right.equalTo(self.contentView).offset(-16);
|
||||
make.width.lessThanOrEqualTo(self.contentView).multipliedBy(0.75);
|
||||
}];
|
||||
|
||||
[self.messageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.bubbleView).offset(10);
|
||||
make.bottom.equalTo(self.bubbleView).offset(-10);
|
||||
make.left.equalTo(self.bubbleView).offset(12);
|
||||
make.right.equalTo(self.bubbleView).offset(-12);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)configureWithMessage:(KBAiChatMessage *)message {
|
||||
self.messageLabel.text = message.text;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user