Commit 4fcd7286 authored by pete谢兆麟's avatar pete谢兆麟

至今按钮添加

parent 4cd869ed
...@@ -155,32 +155,36 @@ class YHWorkExperienceViewController: YHBaseViewController { ...@@ -155,32 +155,36 @@ class YHWorkExperienceViewController: YHBaseViewController {
} }
@objc func keyboardWillShow(_ notification: Notification) { @objc func keyboardWillShow(_ notification: Notification) {
// 当键盘将要显示时调用此函数 if stepView.currentIndex != 0 {
stepView.snp.remakeConstraints { make in // 当键盘将要显示时调用此函数
make.top.equalTo(k_Height_NavigationtBarAndStatuBar) stepView.snp.remakeConstraints { make in
make.left.right.equalTo(view) make.top.equalTo(k_Height_NavigationtBarAndStatuBar)
make.height.equalTo(0) make.left.right.equalTo(view)
} make.height.equalTo(0)
stepView.isHidden = true }
tableView.snp.remakeConstraints { make in stepView.isHidden = true
make.top.equalTo(k_Height_NavigationtBarAndStatuBar) tableView.snp.remakeConstraints { make in
make.bottom.equalTo(-k_Height_safeAreaInsetsBottom() - 64) make.top.equalTo(k_Height_NavigationtBarAndStatuBar)
make.left.right.bottom.equalTo(view) make.bottom.equalTo(-k_Height_safeAreaInsetsBottom() - 64)
make.left.right.bottom.equalTo(view)
}
} }
} }
@objc func keyboardWillHide(_ notification: Notification) { @objc func keyboardWillHide(_ notification: Notification) {
// 当键盘将要隐藏时调用此函数 if stepView.currentIndex != 0 {
stepView.snp.remakeConstraints { make in // 当键盘将要隐藏时调用此函数
make.top.equalTo(k_Height_NavigationtBarAndStatuBar) stepView.snp.remakeConstraints { make in
make.left.right.equalTo(view) make.top.equalTo(k_Height_NavigationtBarAndStatuBar)
make.height.equalTo(104) make.left.right.equalTo(view)
} make.height.equalTo(104)
stepView.isHidden = false }
tableView.snp.remakeConstraints { make in stepView.isHidden = false
make.top.equalTo(k_Height_NavigationtBarAndStatuBar + YHStepView.height) tableView.snp.remakeConstraints { make in
make.bottom.equalTo(-k_Height_safeAreaInsetsBottom() - 64) make.top.equalTo(k_Height_NavigationtBarAndStatuBar + YHStepView.height)
make.left.right.bottom.equalTo(view) make.bottom.equalTo(-k_Height_safeAreaInsetsBottom() - 64)
make.left.right.bottom.equalTo(view)
}
} }
} }
......
...@@ -18,6 +18,7 @@ class YHWorkExperienceItemView: UIView { ...@@ -18,6 +18,7 @@ class YHWorkExperienceItemView: UIView {
var leftButton: UIButton! var leftButton: UIButton!
var rightButton: UIButton! var rightButton: UIButton!
var showPromptLabel: UILabel! var showPromptLabel: UILabel!
var longTimeButton:UIButton!
var dataSource: YHWorkExperienceModel? { var dataSource: YHWorkExperienceModel? {
didSet { didSet {
...@@ -133,10 +134,51 @@ class YHWorkExperienceItemView: UIView { ...@@ -133,10 +134,51 @@ class YHWorkExperienceItemView: UIView {
make.height.equalTo(32) make.height.equalTo(32)
make.width.equalTo(74) make.width.equalTo(74)
} }
longTimeButton = {
let button = UIButton(type: .custom)
button.setImage(UIImage(named: "main_time_normal"), for: .normal)
button.setImage(UIImage(named: "main_time_select"), for: .selected)
button.setTitleColor(UIColor.mainTextColor, for: .normal)
button.setTitle("至今", for: .normal)
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 14)
button.contentHorizontalAlignment = .right
button.addTarget(self, action: #selector(longTimeButtonClick), for: .touchUpInside)
button.imageEdgeInsets = UIEdgeInsets(top: 10, left: 0, bottom: 10, right: 30)
button.isSelected = false
return button
}()
addSubview(longTimeButton)
longTimeButton.snp.makeConstraints { make in
make.right.equalToSuperview()
make.centerY.equalToSuperview()
make.height.equalTo(32)
make.width.equalTo(43)
}
}
@objc func longTimeButtonClick() {
longTimeButton.isSelected = !longTimeButton.isSelected
if longTimeButton.isSelected {
self.dataSource?.message = "至今"
self.updateAllViews()
if let block = self.block {
block(self.dataSource ?? YHWorkExperienceModel())
}
} else {
self.dataSource?.message = ""
self.updateAllViews()
if let block = self.block {
block(self.dataSource ?? YHWorkExperienceModel())
}
}
} }
func updateAllViews() { func updateAllViews() {
guard let dataSource = dataSource else { return } guard let dataSource = dataSource else { return }
if dataSource.id == .id14 || dataSource.id == .id16 || dataSource.id == .id17 {
messageTextField.keyboardType = .numberPad
}
if dataSource.isNeed ?? false { if dataSource.isNeed ?? false {
let str = "*" + (dataSource.title ?? "") let str = "*" + (dataSource.title ?? "")
let attributes: [NSAttributedString.Key: Any] = [ let attributes: [NSAttributedString.Key: Any] = [
...@@ -236,6 +278,34 @@ class YHWorkExperienceItemView: UIView { ...@@ -236,6 +278,34 @@ class YHWorkExperienceItemView: UIView {
} else { } else {
showPromptLabel.isHidden = true showPromptLabel.isHidden = true
} }
if dataSource.id == .id10 {
longTimeButton.isHidden = false
nextStepImageView.isHidden = true
if dataSource.message == "至今" {
longTimeButton.isSelected = true
longTimeButton.snp.remakeConstraints { make in
make.left.equalTo(messageTextField.snp.left)
make.centerY.equalToSuperview()
make.height.equalTo(32)
make.width.equalTo(43)
}
centerButton.isHidden = true
messageTextField.isHidden = true
} else {
longTimeButton.isSelected = false
longTimeButton.snp.remakeConstraints { make in
make.right.equalToSuperview()
make.centerY.equalToSuperview()
make.height.equalTo(32)
make.width.equalTo(43)
}
centerButton.isHidden = false
messageTextField.isHidden = false
}
} else {
longTimeButton.isHidden = true
}
} }
func buttonState(isLeft: Bool) { func buttonState(isLeft: Bool) {
......
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