Skip to content

Instantly share code, notes, and snippets.

@TerryCK
Last active August 8, 2017 02:06
Show Gist options
  • Save TerryCK/707470e71a9e0aab746e1e389828f9c3 to your computer and use it in GitHub Desktop.
Save TerryCK/707470e71a9e0aab746e1e389828f9c3 to your computer and use it in GitHub Desktop.
constraint.swift
let redView = UIView()
redView.backgroundColor = .red
view.addSubview(redView)
redView.translatesAutoresizingMaskIntoConstraints = false
redView.topAnchor.constraint(equalTo: view.topAnchor, constant: 40).isActive = true
redView.rightAnchor.constraint(equalTo: view.rightAnchor, constant: -40).isActive = true
redView.leftAnchor.constraint(equalTo: view.leftAnchor, constant: 40).isActive = true
redView.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -100).isActive = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment