/
DemoCell.swift
35 lines (28 loc) · 1.13 KB
/
DemoCell.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
//
// DemoCell.swift
//
// Created by Mike MacDougall on 1/20/17.
// Copyright © 2017 Etsy. All rights reserved.
//
import UIKit
class DemoCell: UICollectionViewCell {
private let label = UILabel()
override init(frame: CGRect) {
super.init(frame: frame)
label.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(label)
let horizConstraints = NSLayoutConstraint.constraints(withVisualFormat: "H:|-[label]-|", options: NSLayoutConstraint.FormatOptions.init(rawValue: 0), metrics: nil, views: ["label": label])
NSLayoutConstraint.activate(horizConstraints)
let vertConstraints = NSLayoutConstraint.constraints(withVisualFormat: "V:|-[label]-|", options: NSLayoutConstraint.FormatOptions.init(rawValue: 0), metrics: nil, views: ["label": label])
NSLayoutConstraint.activate(vertConstraints)
}
func setTitle(title: String) {
label.text = title
}
func setTitleColor(color: UIColor) {
label.textColor = color
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
}