Skip to content

Commit

Permalink
♻️ :: [#135] custom 버튼 리펙토링
Browse files Browse the repository at this point in the history
  • Loading branch information
Eunho0922 committed Nov 26, 2023
1 parent 38e7c2f commit 2a2a163
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions Projects/Modules/MukgenKit/Sources/DesignSystem/CustomButton.swift
Original file line number Diff line number Diff line change
@@ -1,26 +1,48 @@
import UIKit
import SnapKit
import Then

open class CustomButton: UIButton {

private let textLabel = UILabel().then {
$0.textAlignment = .center
$0.numberOfLines = 1
$0.font = UIFont.systemFont(ofSize: 15, weight: .bold)
}

public init(
title: String,
backgroundColor: UIColor,
titleColor: UIColor,
font: UIFont? = UIFont.systemFont(ofSize: 15, weight: .bold)
) {
let frame = CGRect(x: 0, y: 0, width: 353, height: 55)
super.init(frame: frame)
super.init(frame: .zero)

self.backgroundColor = backgroundColor
setTitleColor(titleColor, for: .normal)
textLabel.text = title
textLabel.textColor = titleColor
textLabel.font = font

layer.cornerRadius = 10

setTitle(title, for: .normal)
titleLabel?.font = font
setupUI()
}

required public init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

private func setupUI() {
addSubview(textLabel)

textLabel.snp.makeConstraints {
$0.centerX.centerY.equalToSuperview()
}

snp.makeConstraints {
$0.width.equalTo(353.0)
$0.height.equalTo(55.0)
}
}
}

0 comments on commit 2a2a163

Please sign in to comment.