Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@lammertw
Created April 3, 2021 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lammertw/f3b4534e34bedcfd28ebbed9bf62b204 to your computer and use it in GitHub Desktop.
Save lammertw/f3b4534e34bedcfd28ebbed9bf62b204 to your computer and use it in GitHub Desktop.
class CountViewController: UIViewController {
private let countLabel = UILabel()
var count = 0 {
didSet {
countLabel.text = "Current count: \(count)"
}
}
init() {
super.init(nibName: nil, bundle: nil)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
count = 0
view.addSubview(countLabel)
// add contrainsts for positioning ...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment