Commit 4fa7262b authored by Steven杜宇's avatar Steven杜宇

// 双选择题cell

parent 80b26797
......@@ -8,6 +8,7 @@
/* Begin PBXBuildFile section */
041B52872B5657B3007EBCEB /* IMAppKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 041B52862B5657B3007EBCEB /* IMAppKey.swift */; };
041B528B2B5E15F1007EBCEB /* YHDoubleChoiceQuestionCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 041B528A2B5E15F1007EBCEB /* YHDoubleChoiceQuestionCell.swift */; };
0468D4202B49320900CFB916 /* YHVerificationCodeLoginController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D41F2B49320900CFB916 /* YHVerificationCodeLoginController.swift */; };
0468D4222B493A5E00CFB916 /* YHPhoneMessageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D4212B493A5E00CFB916 /* YHPhoneMessageView.swift */; };
0468D4242B494BEA00CFB916 /* YHCodeResultViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D4232B494BEA00CFB916 /* YHCodeResultViewController.swift */; };
......@@ -137,6 +138,7 @@
/* Begin PBXFileReference section */
041B52862B5657B3007EBCEB /* IMAppKey.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IMAppKey.swift; sourceTree = "<group>"; };
041B528A2B5E15F1007EBCEB /* YHDoubleChoiceQuestionCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHDoubleChoiceQuestionCell.swift; sourceTree = "<group>"; };
0468D41F2B49320900CFB916 /* YHVerificationCodeLoginController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHVerificationCodeLoginController.swift; sourceTree = "<group>"; };
0468D4212B493A5E00CFB916 /* YHPhoneMessageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHPhoneMessageView.swift; sourceTree = "<group>"; };
0468D4232B494BEA00CFB916 /* YHCodeResultViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCodeResultViewController.swift; sourceTree = "<group>"; };
......@@ -277,6 +279,22 @@
path = IM;
sourceTree = "<group>";
};
041B52882B5E13EB007EBCEB /* FamilyMember */ = {
isa = PBXGroup;
children = (
041B52892B5E14EB007EBCEB /* View */,
);
path = FamilyMember;
sourceTree = "<group>";
};
041B52892B5E14EB007EBCEB /* View */ = {
isa = PBXGroup;
children = (
041B528A2B5E15F1007EBCEB /* YHDoubleChoiceQuestionCell.swift */,
);
path = View;
sourceTree = "<group>";
};
0468D4292B55017400CFB916 /* Analytics */ = {
isa = PBXGroup;
children = (
......@@ -700,6 +718,7 @@
A5C382C82B5E101E00C5E65C /* ServiceProcess(流程) */ = {
isa = PBXGroup;
children = (
041B52882B5E13EB007EBCEB /* FamilyMember */,
);
path = "ServiceProcess(流程)";
sourceTree = "<group>";
......@@ -924,6 +943,7 @@
A5C5B2F92B5515CE00A7C5D1 /* YHPageContentView.swift in Sources */,
A5C5B3232B57BF8F00A7C5D1 /* YHDavidCell1.swift in Sources */,
A5C5B2FB2B5535DF00A7C5D1 /* YHHomeBannerView.swift in Sources */,
041B528B2B5E15F1007EBCEB /* YHDoubleChoiceQuestionCell.swift in Sources */,
A5ACE94B2B4564F7002C94D2 /* BsHUDRotatingImageView.swift in Sources */,
A5ACE94F2B4564F7002C94D2 /* YhOverlayView.swift in Sources */,
A53026902B4E6F2700F35102 /* YHHomeCustomCell.swift in Sources */,
......
//
// YHCheckQuestionCell.swift
// galaxy
//
// Created by edy on 2024/1/22.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
let btnWidth = 70.0
let btnHeight = 32.0
let btnTitleSelectColor = UIColor(hex: 0x4487F9)
let btnTitleDefaultColor = UIColor(hex:0x222222)
let btnBgColor = UIColor(hex:0xF8F9FB)
let confirmTag = 9527
let negativeTag = 9528
class YHDoubleChoiceQuestionCell: UITableViewCell {
static let cellReuseIdentifier = "YHDoubleChoiceQuestionCell"
var question:String? {
didSet {
if let question = question {
let str = "*"+question
let attributes: [NSAttributedString.Key: Any] = [
.font: UIFont.PFSCR(ofSize: 12),
.foregroundColor: UIColor(hex:0x222222)
]
var questionAttrStr = NSMutableAttributedString(string: str, attributes: attributes)
let starRange = NSRange(location: 0, length: 1)
questionAttrStr.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor(hex:0xFF3A3A), range: starRange)
questionLabel.attributedText = questionAttrStr
}
}
}
var selectBlock:((Bool) ->Void)?
var questionLabel: UILabel = {
let label = UILabel()
label.numberOfLines = 0
label.textColor = UIColor(hexString:"#333333")
label.textAlignment = .left
label.font = UIFont.systemFont(ofSize: 14)
return label
}()
lazy var confirmBtn: UIButton = {
let btn = UIButton.bs_button(title: "是".local, font: UIFont.PFSCR(ofSize: 12), normalColor: btnTitleDefaultColor)
btn.backgroundColor = btnBgColor
btn.layer.cornerRadius = btnHeight/2.0
btn.layer.masksToBounds = true
btn.layer.borderWidth = 1
btn.tag = confirmTag
btn.addTarget(self, action: #selector(didClickResponseBtn(btn:)), for: .touchUpInside)
return btn
}()
lazy var negativeBtn: UIButton = {
let btn = UIButton.bs_button(title: "否".local, font: UIFont.PFSCR(ofSize: 12), normalColor: btnTitleDefaultColor)
btn.backgroundColor = btnBgColor
btn.layer.cornerRadius = btnHeight/2.0
btn.layer.masksToBounds = true
btn.layer.borderWidth = 1
btn.tag = negativeTag
btn.addTarget(self, action: #selector(didClickResponseBtn(btn:)), for: .touchUpInside)
return btn
}()
required init?(coder: NSCoder) {
super.init(coder: coder)
}
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupUI()
}
func setupUI() {
self.selectionStyle = .none
question = " 1、是否曾在香港或其他地方因任何罪行或违法行为被定罪?是否曾在香港或其他地方因任何罪行或违法行为被定罪?是否曾在香港或其他地方因任何罪行或违法行为被定罪?是否曾在香港或其他地方因任何罪行或违法行为被定罪?是否曾在香港或其他地方因任何罪行或违法行为被定罪? "
contentView.addSubview(questionLabel)
contentView.addSubview(negativeBtn)
contentView.addSubview(confirmBtn)
// 默认选择否按钮
didClickResponseBtn(btn: negativeBtn)
questionLabel.snp.makeConstraints { make in
make.top.equalTo(contentView.snp.top).offset(12)
make.left.equalToSuperview().offset(16)
make.right.equalToSuperview().offset(-16)
}
negativeBtn.snp.makeConstraints { make in
make.size.equalTo(CGSize(width: btnWidth, height: btnHeight))
make.left.equalTo(questionLabel)
make.top.equalTo(questionLabel.snp.bottom).offset(12)
make.bottom.equalToSuperview().offset(-16)
}
confirmBtn.snp.makeConstraints { make in
make.size.equalTo(CGSize(width: btnWidth, height: btnHeight))
make.left.equalTo(negativeBtn.snp.right).offset(12)
make.centerY.equalTo(negativeBtn)
}
}
@objc func didClickResponseBtn(btn: UIButton) {
let isConfirm = (btn.tag == confirmTag)
confirmBtn.layer.borderColor = (isConfirm ? btnTitleSelectColor : .clear).cgColor
confirmBtn.setTitleColor((isConfirm ? btnTitleSelectColor : btnTitleDefaultColor), for: .normal)
negativeBtn.layer.borderColor = (isConfirm ? .clear : btnTitleSelectColor).cgColor
negativeBtn.setTitleColor((isConfirm ? btnTitleDefaultColor: btnTitleSelectColor), for: .normal)
}
}
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