Created
January 11, 2015 06:45
-
-
Save TomoyaOnishi/4056eab4fe3e4ef97e66 to your computer and use it in GitHub Desktop.
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
override func viewDidLoad() { | |
super.viewDidLoad() | |
let view = UIView(frame: CGRectZero) | |
view.setTranslatesAutoresizingMaskIntoConstraints(false) | |
view.backgroundColor = UIColor.redColor() | |
self.view.addSubview(view) | |
let views = ["view": view] | |
let h = NSLayoutConstraint.constraintsWithVisualFormat("|[view]|", options: nil, metrics: nil, views: views) | |
let v = NSLayoutConstraint.constraintsWithVisualFormat("V:|[view]|", options: nil, metrics: nil, views: views) | |
// This method will be deprecated in a future release. | |
// self.view.addConstraints(h) | |
// self.view.addConstraints(v) | |
NSLayoutConstraint.activateConstraints(h) | |
NSLayoutConstraint.activateConstraints(v) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment