This commit is contained in:
2025-11-12 14:36:15 +08:00
parent afc44cb471
commit 1dbe04cdf9
3 changed files with 78 additions and 11 deletions

View File

@@ -56,6 +56,9 @@
_scrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
_scrollView.alwaysBounceVertical = YES;
_scrollView.showsVerticalScrollIndicator = YES;
//
_scrollView.contentInset = UIEdgeInsetsMake(0, 0, 6, 0);
_scrollView.scrollIndicatorInsets = _scrollView.contentInset;
[self addSubview:_scrollView];
}
@@ -171,7 +174,6 @@
label.textColor = self.labelTextColor;
label.userInteractionEnabled = YES;
label.text = @"";
label.backgroundColor = [UIColor redColor];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleLabelTap:)];
[label addGestureRecognizer:tap];
@@ -196,8 +198,10 @@
NSString *trimmed = [current.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
current.text = trimmed;
self.buffer = trimmed;
[self layoutLabelsForCurrentWidth];
}
//
[self layoutLabelsForCurrentWidth];
[self scrollToBottomIfNeeded];
}
- (void)layoutSubviews {
@@ -247,7 +251,8 @@
CGFloat contentHeight = self.scrollView.contentSize.height;
if (contentHeight > height && height > 0) {
CGPoint bottomOffset = CGPointMake(0, contentHeight - height);
[self.scrollView setContentOffset:bottomOffset animated:YES];
// 使
[self.scrollView setContentOffset:bottomOffset animated:NO];
}
}