Commit 2e4c49be authored by Steven杜宇's avatar Steven杜宇

// 单行双选择cell

parent 4fa7262b
......@@ -9,6 +9,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 */; };
041B528D2B5E58FA007EBCEB /* YHDoubleChoiceFormCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 041B528C2B5E58FA007EBCEB /* YHDoubleChoiceFormCell.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 */; };
......@@ -139,6 +140,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>"; };
041B528C2B5E58FA007EBCEB /* YHDoubleChoiceFormCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHDoubleChoiceFormCell.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>"; };
......@@ -291,6 +293,7 @@
isa = PBXGroup;
children = (
041B528A2B5E15F1007EBCEB /* YHDoubleChoiceQuestionCell.swift */,
041B528C2B5E58FA007EBCEB /* YHDoubleChoiceFormCell.swift */,
);
path = View;
sourceTree = "<group>";
......@@ -924,6 +927,7 @@
A5ACE9542B4564F7002C94D2 /* YHNavigationController.swift in Sources */,
A5ACE95E2B4571BF002C94D2 /* YHHomeViewController.swift in Sources */,
A5ACE93D2B4564F7002C94D2 /* UIButton+Extension.swift in Sources */,
041B528D2B5E58FA007EBCEB /* YHDoubleChoiceFormCell.swift in Sources */,
A5ACE9292B4564F7002C94D2 /* YHSmsCodeInputView.swift in Sources */,
A5ACE9452B4564F7002C94D2 /* BsHUDContainerView.swift in Sources */,
A5ACE93A2B4564F7002C94D2 /* NSAttributedString+Extension.swift in Sources */,
......
//
// YHDoubleChoiceFormCell.swift
// galaxy
//
// Created by edy on 2024/1/22.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHDoubleChoiceFormCell: UITableViewCell {
static let cellReuseIdentifier = "YHDoubleChoiceFormCell"
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
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 questionLabel: UILabel = {
let label = UILabel()
label.textColor = UIColor(hexString:"#333333")
label.textAlignment = .left
label.numberOfLines = 0
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(22)
make.left.equalToSuperview().offset(16)
make.right.equalTo(confirmBtn.snp.left).offset(-8)
make.bottom.equalTo(contentView.snp.bottom).offset(-22)
}
negativeBtn.snp.makeConstraints { make in
make.size.equalTo(CGSize(width: btnWidth, height: btnHeight))
make.right.equalToSuperview().offset(-16)
make.top.equalToSuperview().offset(16)
}
confirmBtn.snp.makeConstraints { make in
make.size.equalTo(CGSize(width: btnWidth, height: btnHeight))
make.right.equalTo(negativeBtn.snp.left).offset(-8)
make.top.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)
}
}
......@@ -8,17 +8,17 @@
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"
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
var question:String? {
didSet {
......
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