处理滚动底部问题
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
|
||||
@property (nonatomic, strong) UIView *bubbleView;
|
||||
@property (nonatomic, strong) UILabel *messageLabel;
|
||||
@property (nonatomic, strong) UIActivityIndicatorView *loadingIndicator;
|
||||
|
||||
@end
|
||||
|
||||
@@ -44,12 +45,20 @@
|
||||
self.messageLabel.textColor = [UIColor blackColor];
|
||||
[self.bubbleView addSubview:self.messageLabel];
|
||||
|
||||
// 加载指示器
|
||||
self.loadingIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
|
||||
self.loadingIndicator.hidesWhenStopped = YES;
|
||||
[self.contentView addSubview:self.loadingIndicator];
|
||||
|
||||
// 布局约束
|
||||
[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);
|
||||
// 最小高度约束,确保 loading 时气泡不消失
|
||||
make.height.greaterThanOrEqualTo(@40);
|
||||
make.width.greaterThanOrEqualTo(@50);
|
||||
}];
|
||||
|
||||
[self.messageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
@@ -58,10 +67,24 @@
|
||||
make.left.equalTo(self.bubbleView).offset(12);
|
||||
make.right.equalTo(self.bubbleView).offset(-12);
|
||||
}];
|
||||
|
||||
[self.loadingIndicator mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerY.equalTo(self.contentView);
|
||||
make.right.equalTo(self.contentView).offset(-16);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)configureWithMessage:(KBAiChatMessage *)message {
|
||||
self.messageLabel.text = message.text;
|
||||
|
||||
if (message.isLoading) {
|
||||
self.bubbleView.hidden = YES;
|
||||
[self.loadingIndicator startAnimating];
|
||||
} else {
|
||||
self.bubbleView.hidden = NO;
|
||||
self.messageLabel.hidden = NO;
|
||||
[self.loadingIndicator stopAnimating];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user