Created
March 28, 2021 06:08
-
-
Save kbw2204/091da587ae2739ea3e7717e583d481d6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// | |
// RepoTableViewCell.swift | |
// GithubSearch_VIPER | |
// | |
// Created by 융융 on 2021/03/28. | |
// | |
import UIKit | |
final class RepoTableViewCell: UITableViewCell { | |
private let stackView = UIStackView().then { | |
$0.axis = .vertical | |
$0.translatesAutoresizingMaskIntoConstraints = false | |
} | |
private let titleLabel = UILabel().then { | |
$0.font = .systemFont(ofSize: 20) | |
$0.textColor = .label | |
} | |
private let subTitleLabel = UILabel().then { | |
$0.font = .systemFont(ofSize: 12) | |
$0.textColor = .label | |
} | |
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { | |
super.init(style: style, reuseIdentifier: reuseIdentifier) | |
self.configureUI() | |
self.setupConstrint() | |
} | |
required init?(coder: NSCoder) { | |
fatalError("init(coder:) has not been implemented") | |
} | |
} | |
// MARK: - private | |
extension RepoTableViewCell { | |
private func configureUI() { | |
[titleLabel, subTitleLabel].forEach { [weak self] in | |
self?.stackView.addArrangedSubview($0) | |
} | |
self.contentView.addSubview(self.stackView) | |
} | |
private func setupConstrint() { | |
self.stackView.snp.makeConstraints { | |
$0.leading.trailing.equalToSuperview().inset(8) | |
$0.centerY.equalToSuperview() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment