Skip to content

Commit

Permalink
#171: 라디오버튼 + 타이틀 컴포넌트 > RadioButtonView 생성
Browse files Browse the repository at this point in the history
dev-muuu committed Feb 10, 2023
1 parent a5f8309 commit 3305b7f
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions Zatch/Global/Source/Component/RadioButtonView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//
// RadioButtonView.swift
// Zatch
//
// Created by 박소윤 on 2023/02/10.
//

import Foundation

extension ZatchComponent{

class RadioButtonView: BaseView{

var isSelected = false{
didSet{
radioButton.isSelected = isSelected
self.tag = isSelected ? Const.ViewTag.select : Const.ViewTag.unselect
}
}

private let stackView = UIStackView().then{
$0.isUserInteractionEnabled = true
$0.spacing = 8
$0.axis = .horizontal
}

private lazy var radioButton = UIButton().then{
$0.isUserInteractionEnabled = false
$0.setImage(Image.zatchUncheck, for: .normal)
$0.setImage(Image.zatchCheck, for: .selected)
}

private let titleLabel = UILabel().then{
$0.setTypoStyleWithSingleLine(typoStyle: .medium14)
$0.textColor = .black85
}

override func hierarchy() {
self.addSubview(stackView)
stackView.addArrangedSubview(radioButton)
stackView.addArrangedSubview(titleLabel)
}

override func layout() {
stackView.snp.makeConstraints{
$0.top.leading.trailing.bottom.equalToSuperview()
}
radioButton.snp.makeConstraints{
$0.width.height.equalTo(24)
}
}

func setTitle(_ title: String){
titleLabel.text = title
}
}
}

0 comments on commit 3305b7f

Please sign in to comment.