Commit 82461af4 authored by Alex朱枝文's avatar Alex朱枝文

发布动态调整

parent 024fd1e4
......@@ -300,14 +300,16 @@ class YHCirclePublishViewController: YHBaseViewController {
// 动态更新 TextView 高度
private func updateTextViewHeight(_ textView: UITextView) {
let size = textView.sizeThatFits(CGSize(width: textView.frame.width, height: .infinity))
let width = textView.frame.width > 0 ? textView.frame.width : UIScreen.main.bounds.width - marginX * 2
let size = textView.sizeThatFits(CGSize(width: width, height: .infinity))
// 设置最小和最大高度限制
let minHeight: CGFloat = textView == self.textView ? 24 : 92
let maxHeight: CGFloat = textView == self.textView ? 100 : CGFloat.infinity
let newHeight = min(max(size.height, minHeight), maxHeight)
if abs(newHeight - textView.frame.size.height) > 1 {
let currentHeight = textView.frame.size.height
if abs(newHeight - currentHeight) > 1 || currentHeight == 0 {
textView.snp.updateConstraints { make in
make.height.equalTo(newHeight)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment