Commit ff737973 authored by Steven杜宇's avatar Steven杜宇

// AI

parent 25820cf8
......@@ -17,6 +17,7 @@ class YHAutoTextView: UITextView, UITextViewDelegate {
}
}
let maxHeight = 105.0
var placeHolder: String = "" {
didSet {
placeholderLabel.text = placeHolder
......@@ -55,17 +56,24 @@ class YHAutoTextView: UITextView, UITextViewDelegate {
placeholderLabel.isHidden = !textView.text.isEmpty
text = textView.text
}
override var intrinsicContentSize: CGSize {
// 计算内容的尺寸
// var height = self.getHeight(text: self.text, font: self.font!, width: frame.width)
// if height < 20.0 {
// height = 20.0
// }
// // 加上textView周边的缝隙
// height += 15.0
// var height = self.getHeight(text: self.text, font: self.font!, width: frame.width)
// if height < 20.0 {
// height = 20.0
// }
// // 加上textView周边的缝隙
// height += 15.0
let size = sizeThatFits(CGSize(width: frame.width, height: .greatestFiniteMagnitude))
return CGSize(width: size.width, height: size.height)
var height = size.height
isScrollEnabled = height > maxHeight
if height > maxHeight {
height = maxHeight
}
return CGSize(width: size.width, height: height)
}
func getHeight(text:String, font:UIFont, width:CGFloat)->CGFloat {
......
......@@ -84,7 +84,7 @@ class YHAITextInputView: UIView {
contentView.snp.makeConstraints { make in
make.left.equalTo(20)
make.top.equalTo(10)
make.bottom.equalTo(-10)
make.bottom.equalTo(-10-k_Height_safeAreaInsetsBottom())
make.right.equalTo(-20)
}
......@@ -113,6 +113,10 @@ class YHAITextInputView: UIView {
let isKeyboardShow = notification.name == UIResponder.keyboardWillShowNotification
let bottomMargin = (isKeyboardShow ? -keyboardFrame.height : 0)
contentView.snp.updateConstraints { make in
make.bottom.equalTo(-10-(isKeyboardShow ? 0.0 : k_Height_safeAreaInsetsBottom()))
}
self.snp.updateConstraints { make in
make.bottom.equalTo(bottomMargin)
}
......
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