-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#171: 디자인 컴포넌트 '글자와 화살표' > LettersAndArrowView 생성
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// | ||
// LettersAndArrowView.swift | ||
// Zatch | ||
// | ||
// Created by 박소윤 on 2023/02/08. | ||
// | ||
|
||
import Foundation | ||
|
||
extension ZatchComponent{ | ||
|
||
class LettersAndArrowView: BaseView{ | ||
|
||
var isSelected = false{ | ||
didSet{ | ||
arrowImage.image = isSelected ? Image.arrowUp : Image.arrowDown | ||
} | ||
} | ||
|
||
private let stackView = UIStackView().then{ | ||
$0.spacing = 4 | ||
$0.axis = .horizontal | ||
} | ||
private let label = UILabel().then{ | ||
$0.setTypoStyleWithSingleLine(typoStyle: .medium16) | ||
$0.textColor = .black85 | ||
} | ||
private let arrowImage = UIImageView().then{ | ||
$0.image = Image.arrowDown | ||
} | ||
|
||
override func hierarchy() { | ||
self.addSubview(stackView) | ||
stackView.addArrangedSubview(label) | ||
stackView.addArrangedSubview(arrowImage) | ||
} | ||
|
||
override func layout() { | ||
stackView.snp.makeConstraints{ | ||
$0.top.leading.trailing.bottom.equalToSuperview() | ||
} | ||
arrowImage.snp.makeConstraints{ | ||
$0.width.height.equalTo(20) | ||
$0.top.bottom.trailing.equalToSuperview() | ||
} | ||
} | ||
|
||
func setTitle(_ title: String){ | ||
label.text = title | ||
} | ||
} | ||
} |