Commit a9c42df9 authored by David黄金龙's avatar David黄金龙

处理 一处展示

parent 6e96038b
......@@ -130,6 +130,9 @@ class YHBasicInfoFillView: UIView, UITextViewDelegate {
private var lastSelectedBtn : UIButton?
private var myTextView : UITextView!
private var arrCheckBtns : [UIButton] = []
private let kTipsString : String = "如选择“是”,请详细说明"
}
......@@ -190,6 +193,8 @@ private extension YHBasicInfoFillView {
myTextView = textView
myTextView.delegate = self
// NotificationCenter.default.addObserver(self, selector: #selector(textViewDidChange?(<#T##textView: UITextView##UITextView#>)), name: textDidChangeNotification, object: nil)
textView.contentInset = UIEdgeInsets(top: -8, left: 0, bottom: 0, right: 0)
......@@ -293,16 +298,13 @@ private extension YHBasicInfoFillView {
private func updateUI() {
guard let model = model else { return }
arrCheckBtns.removeAll()
if model.type == 1 {
additionHoldView.isHidden = true
mutilChoiceHoldView.isHidden = false
let lable = UILabel()
let str = "*选择成员:"
let str = "* 选择成员:"
let attributes: [NSAttributedString.Key: Any] = [
.font: UIFont.PFSC_R(ofSize: 14),
.foregroundColor: UIColor.mainTextColor
......@@ -332,7 +334,7 @@ private extension YHBasicInfoFillView {
let btn = UIButton(type: .custom)
btn.setTitle(name, for: .normal)
btn.setTitle(name, for: .selected)
btn.titleLabel?.font = UIFont.PFSC_R(ofSize: 13)
btn.titleLabel?.font = UIFont.PFSC_M(ofSize: 14)
btn.setTitleColor(UIColor.mainTextColor, for: .normal)
btn.setTitleColor(UIColor.brandMainColor, for: .selected)
btn.setImage(UIImage(named: "basic_info_check_0"), for: .normal)
......@@ -342,8 +344,6 @@ private extension YHBasicInfoFillView {
btn.addTarget(self, action: #selector(clickCheckBtn(sender:)), for: .touchUpInside)
mutilChoiceHoldView.addSubview(btn)
// btn.backgroundColor = .red//for test hjl
if targetId == item.id {
btn.isSelected = true
} else {
......@@ -374,7 +374,7 @@ private extension YHBasicInfoFillView {
title = model.question
if model.answer == "Y" {
didClickResponseBtn(btn: answer2Btn)
myTextView.text = model.additionDes
myTextView.text = model.additionDes.count > 0 ? model.additionDes : kTipsString
} else {
if model.answer == "N" {
didClickResponseBtn(btn: answer1Btn)
......@@ -383,7 +383,7 @@ private extension YHBasicInfoFillView {
targetView = btn
arrCheckBtns.append(btn)
}
} else {
additionHoldView.isHidden = false
......@@ -392,38 +392,68 @@ private extension YHBasicInfoFillView {
title = model.question
if model.answer == "Y" {
didClickResponseBtn(btn: answer2Btn)
myTextView.text = model.additionDes
myTextView.text = model.additionDes.count > 0 ? model.additionDes : kTipsString
} else {
if model.answer == "N" {
didClickResponseBtn(btn: answer1Btn)
}
}
}
if myTextView.text == kTipsString {
myTextView.textColor = UIColor(hexString: "#C0C0C0")
} else {
myTextView.textColor = UIColor.mainTextColor
}
}
}
extension YHBasicInfoFillView : UITextFieldDelegate {
private func textViewDidBeginEditing (textView: UITextView) {
// if myTextView.isFirstResponder {
// myTextView.text = nil
// myTextView.textColor = .white
// }
}
func textViewShouldBeginEditing(_ textView: UITextView) -> Bool {
if textView.text == kTipsString {
textView.text = ""
}
textView.textColor = UIColor.mainTextColor
return true
}
private func textViewDidEndEditing (textView: UITextView) {
func textViewShouldEndEditing(_ textView: UITextView) -> Bool {
if textView.text.isEmpty || textView.text == "" {
textView.textColor = UIColor(hexString: "#C0C0C0")
textView.text = "如选择“是”,请详细说明"
textView.text = kTipsString
}
textView.textColor = UIColor.mainTextColor
return true
}
internal func textViewDidChange(_ textView: UITextView) {
if textView.text == kTipsString {
model?.additionDes = ""
} else {
textView.textColor = UIColor.mainTextColor
model?.additionDes = textView.text
}
textView.textColor = UIColor.mainTextColor
}
@objc func clickCheckBtn(sender : UIButton) {
sender.isSelected = !sender.isSelected
//修改成单选逻辑
if sender.isSelected != true {
for item in arrCheckBtns {
item.isSelected = false
}
sender.isSelected = true
}
}
}
......
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