Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save raonivaladares/2728b7b1db7f35a6013635f712b90a58 to your computer and use it in GitHub Desktop.
Save raonivaladares/2728b7b1db7f35a6013635f712b90a58 to your computer and use it in GitHub Desktop.
import UIKit
class FirstViewController: UIViewController {
private let topicLabel: UILabel = {
let label = UILabel()
label.text = "Topic"
label.textAlignment = .center
label.translatesAutoresizingMaskIntoConstraints = false
return label
}()
// MARK: - View lify-cicle
override func viewDidLoad() {
super.viewDidLoad()
buildUI()
}
// MARK: - Private methods
private func buildUI() {
view.backgroundColor = .white
view.addSubview(topicLabel)
NSLayoutConstraint.activate([
topicLabel.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
topicLabel.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
topicLabel.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment