Created
August 8, 2017 02:12
-
-
Save TerryCK/8e4ce3e370d022219498032d34ad1f4e to your computer and use it in GitHub Desktop.
NSLayoutConstraint.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let redView = UIView() | |
redView.backgroundColor = .red | |
view.addSubview(redView) | |
redView.translatesAutoresizingMaskIntoConstraints = false | |
NSLayoutConstraint.activate([ | |
redView.topAnchor.constraint(equalTo: view.topAnchor, constant: 40), | |
redView.rightAnchor.constraint(equalTo: view.rightAnchor, constant: -40), | |
redView.leftAnchor.constraint(equalTo: view.leftAnchor, constant: 40), | |
redView.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -100), | |
]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment