Commit 25820cf8 authored by Steven杜宇's avatar Steven杜宇

// AI

parent 2ed3887d
......@@ -27,12 +27,13 @@ class YHAutoTextView: UITextView, UITextViewDelegate {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.textColor = UIColor.lightGray
label.font = UIFont.PFSC_R(ofSize: 15)
label.font = UIFont.PFSC_R(ofSize: 14)
return label
}()
override init(frame: CGRect, textContainer: NSTextContainer?) {
super.init(frame: frame, textContainer: textContainer)
self.font = .PFSC_R(ofSize: 14)
delegate = self
isScrollEnabled = false // 禁止滚动
self.addSubview(placeholderLabel)
......@@ -57,7 +58,20 @@ class YHAutoTextView: UITextView, UITextViewDelegate {
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
let size = sizeThatFits(CGSize(width: frame.width, height: .greatestFiniteMagnitude))
return CGSize(width: size.width, height: size.height)
}
func getHeight(text:String, font:UIFont, width:CGFloat)->CGFloat {
let size = CGSize.init(width:width , height: CGFloat(MAXFLOAT))
let dic = [NSAttributedString.Key.font: font]
let strSize = text.boundingRect(with: size, options: [.usesLineFragmentOrigin], attributes: dic, context:nil).size
return CGSizeMake(strSize.width, ceil(strSize.height)).height
}
}
......@@ -33,6 +33,7 @@ class YHAITextInputView: UIView {
let btn = UIButton(type: .custom)
btn.backgroundColor = .red
btn.addTarget(self, action: #selector(didSendButtonClicked), for: .touchUpInside)
btn.YH_clickEdgeInsets = UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20)
return btn
}()
......@@ -88,21 +89,19 @@ class YHAITextInputView: UIView {
}
sendBtn.snp.makeConstraints { make in
make.width.equalTo(50)
make.height.equalTo(50)
make.width.equalTo(24)
make.height.equalTo(24)
make.right.equalTo(-16)
make.bottom.equalTo(-13)
make.bottom.equalTo(-10)
}
textView.snp.makeConstraints { make in
make.left.equalTo(16)
make.top.equalTo(16)
make.bottom.equalTo(-16)
make.right.equalTo(sendBtn.snp.left).offset(-10)
make.left.equalTo(5)
make.top.equalTo(4)
make.bottom.equalTo(-4)
make.right.equalTo(sendBtn.snp.left).offset(-5)
}
addKeyBoardNotify()
}
@objc func handleKeyboardNotification(_ notification: Notification) {
......
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