Created
June 8, 2014 08:39
-
-
Save jweinberg/01f39628407db8f942bc 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
import UIKit | |
class TestView: UIView { | |
override func intrinsicContentSize() -> CGSize { | |
return CGSizeMake(100, 100) | |
} | |
} | |
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
self.view.backgroundColor = UIColor.greenColor() | |
var leftView = TestView(frame: CGRectMake(0, 0, 100, 100)) | |
leftView.setTranslatesAutoresizingMaskIntoConstraints(false) | |
leftView.backgroundColor = UIColor.redColor() | |
var rightView = TestView(frame: CGRectMake(0, 0, 100, 100)) | |
rightView.setTranslatesAutoresizingMaskIntoConstraints(false) | |
rightView.backgroundColor = UIColor.magentaColor() | |
self.view.addSubview(leftView) | |
self.view.addSubview(rightView) | |
var constraints = H(|-leftView-rightView-|) | |
constraints += V(|-leftView-|) | |
constraints += V(|-rightView-|) | |
self.view.addConstraints(constraints) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment