From 8115d67875e779576701ef32182ade0c3a5e2123 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=80=ED=98=B8?= <127753071+Eunho0922@users.noreply.github.com> Date: Mon, 1 Jan 2024 22:56:01 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20::=20[#135]=20=EB=A8=B9=EC=A0=A0=20?= =?UTF-8?q?=ED=83=80=EC=9D=B4=ED=8B=80=20=EB=A0=88=EC=9D=B4=EB=B8=94=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UILabel/Auth/MukgenTitleLabel.swift | 59 +++++++++++++++---- 1 file changed, 46 insertions(+), 13 deletions(-) diff --git a/Projects/Modules/MukgenKit/Sources/DesignSystem/UILabel/Auth/MukgenTitleLabel.swift b/Projects/Modules/MukgenKit/Sources/DesignSystem/UILabel/Auth/MukgenTitleLabel.swift index 73a77a2..4796ae8 100644 --- a/Projects/Modules/MukgenKit/Sources/DesignSystem/UILabel/Auth/MukgenTitleLabel.swift +++ b/Projects/Modules/MukgenKit/Sources/DesignSystem/UILabel/Auth/MukgenTitleLabel.swift @@ -2,48 +2,81 @@ import UIKit import SnapKit import Then -open class CustomTitleUILabel: UILabel { +open class MukgenTitleLabel: UIView{ private let titleLabel = UILabel().then { $0.textColor = .black $0.font = UIFont.systemFont(ofSize: 24, weight: .semibold) + $0.textAlignment = .left + $0.backgroundColor = .clear + } + + private let subTitleLabel = UILabel().then { + $0.textColor = MukgenKitAsset.Colors.primaryDark1.color + $0.font = UIFont.systemFont(ofSize: 16, weight: .regular) + $0.backgroundColor = .clear + $0.textAlignment = .left + $0.numberOfLines = 1 } public init ( - text: String, - lineNumber: Int? = 1 + type: MukgenTitleLabelType ) { super.init(frame: .zero) - titleLabel.text = text - titleLabel.numberOfLines = lineNumber ?? 1 + titleLabel.text = type.title + subTitleLabel.text = type.subTitle + titleLabel.numberOfLines = type.titleNuberOfLine ?? 1 - setupUI(line: lineNumber ?? 1) + setupUI(type: type, numberOfLines: type.titleNuberOfLine ?? 1) } required public init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } - private func setupUI(line: Int) { - switch line { + private func setupUI(type: MukgenTitleLabelType, numberOfLines: Int) { + switch numberOfLines { case 1: titleLabel.snp.makeConstraints { $0.height.equalTo(29.0) } - break case 2: titleLabel.snp.makeConstraints { $0.height.equalTo(58.0) } - break default: break } - addSubview(titleLabel) - titleLabel.snp.makeConstraints { - $0.edges.equalToSuperview() + if type.subTitle == nil { + addSubview(titleLabel) + + titleLabel.snp.makeConstraints { + $0.edges.equalToSuperview() + } + } else if type == MukgenTitleLabelType.startTitle { + addSubviews([titleLabel, subTitleLabel]) + titleLabel.snp.makeConstraints { + $0.leading.equalToSuperview() + $0.top.equalToSuperview() + } + + subTitleLabel.snp.makeConstraints { + $0.leading.equalToSuperview() + $0.top.equalTo(titleLabel.snp.bottom).offset(24.0) + } + } else { + addSubviews([titleLabel, subTitleLabel]) + titleLabel.snp.makeConstraints { + $0.leading.equalToSuperview() + $0.top.equalToSuperview() + } + + subTitleLabel.snp.makeConstraints { + $0.leading.equalToSuperview() + $0.top.equalTo(titleLabel.snp.bottom).offset(12.0) + } } } }