-
Notifications
You must be signed in to change notification settings - Fork 13
/
TitleViewController.swift
49 lines (39 loc) · 1.33 KB
/
TitleViewController.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
46
47
48
49
//
// TitleViewController.swift
// ACKategories
//
// Created by Jakub Olejník on 12/09/2018.
// Copyright © 2018 Ackee, s.r.o. All rights reserved.
//
import UIKit
import ACKategories
class TitleViewController: BaseViewControllerNoVM {
private(set) weak var nameLabel: UILabel!
private let name: String
private let color: UIColor
// MARK: Initializers
init(name: String, color: UIColor) {
self.name = name
self.color = color
super.init()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// MARK: View life cycle
override func loadView() {
super.loadView()
view.backgroundColor = color
let nameLabel = UILabel()
nameLabel.textAlignment = .center
nameLabel.text = name
view.addSubview(nameLabel)
nameLabel.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
nameLabel.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 20),
nameLabel.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor, constant: 20),
nameLabel.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor, constant: -20)
])
self.nameLabel = nameLabel
}
}