Last active
August 3, 2017 16:31
Revisions
-
fdstevex revised this gist
Jun 4, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ // Auto layout in a Swift Playground (for iOS). import UIKit -
fdstevex revised this gist
Jun 4, 2014 . No changes.There are no files selected for viewing
-
fdstevex revised this gist
Jun 3, 2014 . 1 changed file with 4 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,9 @@ // Auto layout in a Swift Playground. import UIKit var v = UIView() v.frame = CGRectMake(0, 0, 200, 200) var b1 = UIButton() b1.setTitle("Click Me", forState:UIControlState.Normal) @@ -27,12 +25,12 @@ v.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-[b1]-|", op v.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-[b2]-|", options: nil, metrics: nil, views: views)) v.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|-[b1]-[b2]", options: nil, metrics: nil, views: views)) v.layoutIfNeeded() b1.frame b2.frame v.frame v -
fdstevex revised this gist
Jun 3, 2014 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ // Trying to get auto layout to work in a Swift Playground. // This example should show a view with two buttons, one on top of the other. // But instead, the frames are all nil. @@ -29,8 +29,10 @@ v.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-[b2]-|", op v.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|-[b1]-[b2]-|", options: nil, metrics: nil, views: views)) v.layoutIfNeeded() b1.frame b2.frame v.frame v -
fdstevex revised this gist
Jun 3, 2014 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,6 @@ // Trying to get auto layout to work in a Swift Playground. // This example should show a view with two buttons, one on top of the other. // But instead, the frames are all nil. import UIKit @@ -31,3 +33,4 @@ b1.frame b2.frame v.frame v -
fdstevex created this gist
Jun 3, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ // Playground - noun: a place where people can play import UIKit var v = UIView() v.setTranslatesAutoresizingMaskIntoConstraints(false) var b1 = UIButton() b1.setTitle("Click Me", forState:UIControlState.Normal) b1.setTitleColor(UIColor.blueColor(), forState: UIControlState.Normal) b1.setTranslatesAutoresizingMaskIntoConstraints(false) v.addSubview(b1) var b2 = UIButton() b2.setTitle("Click Me Too", forState:UIControlState.Normal) b2.setTitleColor(UIColor.blueColor(), forState: UIControlState.Normal) b2.setTranslatesAutoresizingMaskIntoConstraints(false) v.addSubview(b2) var views = Dictionary<String, UIView>() views["b1"] = b1 views["b2"] = b2 v.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-[b1]-|", options: nil, metrics: nil, views: views)) v.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-[b2]-|", options: nil, metrics: nil, views: views)) v.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|-[b1]-[b2]-|", options: nil, metrics: nil, views: views)) b1.frame b2.frame v.frame