diff options
author | Nicholas Tay <nick@windblume.net> | 2022-03-18 14:04:12 +1100 |
---|---|---|
committer | Nicholas Tay <nick@windblume.net> | 2022-03-18 14:04:51 +1100 |
commit | f45d90ba504496e68d6a4cb2f7f887c011e9b19d (patch) | |
tree | a201aa4fa16a24d8538eb865bcb7fcfdafe27f2a /foray/ForayNewTableViewCell.swift | |
parent | 16d2dc26ac31f2c5ec3dfd72228d2e7997459028 (diff) | |
download | forayios-f45d90ba504496e68d6a4cb2f7f887c011e9b19d.tar.gz forayios-f45d90ba504496e68d6a4cb2f7f887c011e9b19d.tar.bz2 forayios-f45d90ba504496e68d6a4cb2f7f887c011e9b19d.zip |
Split table view cell into separate file
Cell no longer uses prototypes as registered in the Storyboard. Instead
is a custom class inheriting the UITableViewCell and is manually
registered by the VC.
This is a first step towards reimplementing the prototype cells. Only
has one label at the moment.
Diffstat (limited to '')
-rw-r--r-- | foray/ForayNewTableViewCell.swift | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/foray/ForayNewTableViewCell.swift b/foray/ForayNewTableViewCell.swift new file mode 100644 index 0000000..b2b22af --- /dev/null +++ b/foray/ForayNewTableViewCell.swift @@ -0,0 +1,39 @@ +// +// ForayNewTableViewCell.swift +// foray +// +// Created by Nicholas Tay on 18/3/2022. +// + +import UIKit +import SnapKit + +class ForayNewTableViewCell: UITableViewCell { + + let nameLabel: UILabel = UILabel() + + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + super.init(style: style, reuseIdentifier: reuseIdentifier) + initialiseViews() + } + + required init?(coder: NSCoder) { + fatalError("unreachable") + } + + private func initialiseViews() { + contentView.addSubview(nameLabel) + setupConstraints() + } + + private func setupConstraints() { + nameLabel.snp.makeConstraints { (make) in + make.top.bottom.equalToSuperview().inset(8) + make.leading.trailing.equalToSuperview().inset(8) + } + } + + public func setData(str: String) { + nameLabel.text = str + } +} |