Skip to content

Commit

Permalink
✨ :: [#135] 먹젠 타이틀 레이블 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Eunho0922 committed Jan 1, 2024
1 parent e8b6624 commit 8115d67
Showing 1 changed file with 46 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
}
Expand Down

0 comments on commit 8115d67

Please sign in to comment.