-
Notifications
You must be signed in to change notification settings - Fork 88
/
Copy pathCustomTableViewCell.swift
45 lines (33 loc) · 1.43 KB
/
CustomTableViewCell.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import UIKit
import Static
final class CustomTableViewCell: UITableViewCell, Cell {
// MARK: - Properties
private lazy var centeredLabel: UILabel = {
let label = UILabel()
label.textAlignment = .center
label.textColor = .white
label.translatesAutoresizingMaskIntoConstraints = false
return label
}()
// MARK: - Initialization
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
contentView.backgroundColor = .gray
contentView.addSubview(centeredLabel)
NSLayoutConstraint.activate([
centeredLabel.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 8),
centeredLabel.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: 8),
centeredLabel.centerXAnchor.constraint(equalTo: contentView.centerXAnchor),
centeredLabel.leadingAnchor.constraint(greaterThanOrEqualTo: contentView.leadingAnchor, constant: 8),
centeredLabel.trailingAnchor.constraint(lessThanOrEqualTo: contentView.trailingAnchor, constant: -8)
])
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// MARK: - CellType
func configure(row: Row) {
centeredLabel.text = row.text
accessibilityIdentifier = row.accessibilityIdentifier
}
}