Skip to content

Instantly share code, notes, and snippets.

@sturdysturge
Created February 4, 2021 22:21
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 sturdysturge/fc44af97b823663a23b19ea4cf81fbc2 to your computer and use it in GitHub Desktop.
Save sturdysturge/fc44af97b823663a23b19ea4cf81fbc2 to your computer and use it in GitHub Desktop.
import UIKit
class ViewController: UIViewController {
var labelText = UILabel(frame: .zero)
override func viewDidLoad() {
super.viewDidLoad()
view.addSubview(labelText)
labelText.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
labelText.centerYAnchor.constraint(equalTo: view.centerYAnchor),
labelText.centerXAnchor.constraint(equalTo: view.centerXAnchor)
])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment