Last active
February 1, 2016 10:30
-
-
Save vienvu89/6599f56577831533b22a to your computer and use it in GitHub Desktop.
Revisions
-
vienvu89 revised this gist
Feb 1, 2016 . 1 changed file with 5 additions and 3 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,7 +1,8 @@ //Add constraint with top left right bottom is (0, 0, 0, 0) func addChildToContainer(parent container: UIView, child childView: UIView) { container.addSubview(childView) childView.translatesAutoresizingMaskIntoConstraints = false let views = Dictionary(dictionaryLiteral: ("childView", childView),("container", container)) //Horizontal constraints let horizontalConstraints = NSLayoutConstraint.constraintsWithVisualFormat("H:|[childView]|", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: views) @@ -14,8 +15,9 @@ func addConstraintsChildToContainer(parent container: UIView, child childView: U //Add constraint with top left right bottom is same with option UIEdgeInsets func addChildToContainer(parent container: UIView, child childView: UIView, andInsets insets: UIEdgeInsets) { container.addSubview(childView) childView.translatesAutoresizingMaskIntoConstraints = false let views = Dictionary(dictionaryLiteral: ("childView", childView),("container", container)) //Horizontal constraints let horizontalConstraints = NSLayoutConstraint.constraintsWithVisualFormat("H:|-\(insets.left)-[childView]-\(insets.right)-|", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: views) @@ -24,4 +26,4 @@ func addConstraintsChildToContainer(parent container: UIView, child childView: U //Vertical constraints let verticalConstraints = NSLayoutConstraint.constraintsWithVisualFormat("V:|-\(insets.top)-[childView]-\(insets.bottom)-|", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: views) container.addConstraints(verticalConstraints) } -
vienvu89 renamed this gist
Jan 9, 2016 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
vienvu89 renamed this gist
Jan 8, 2016 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
vienvu89 renamed this gist
Jan 8, 2016 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
vienvu89 revised this gist
Jan 8, 2016 . 1 changed file with 2 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,6 +1,6 @@ //Add constraint with top left right bottom is (0, 0, 0, 0) func addConstraintsChildToContainer(parent container: UIView, child childView: UIView) { container.addSubview(childView) let views = Dictionary(dictionaryLiteral: ("childView", childView),("container", container)) //Horizontal constraints @@ -14,7 +14,7 @@ func addChildToContainer(parent container: UIView, child childView: UIView) { //Add constraint with top left right bottom is same with option UIEdgeInsets func addConstraintsChildToContainer(parent container: UIView, child childView: UIView, andInsets insets: UIEdgeInsets) { container.addSubview(childView) let views = Dictionary(dictionaryLiteral: ("childView", childView),("container", container)) //Horizontal constraints -
vienvu89 revised this gist
Jan 8, 2016 . No changes.There are no files selected for viewing
-
vienvu89 created this gist
Jan 8, 2016 .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,27 @@ //Add constraint with top left right bottom is (0, 0, 0, 0) func addChildToContainer(parent container: UIView, child childView: UIView) { container.addSubview(childView) let views = Dictionary(dictionaryLiteral: ("childView", childView),("container", container)) //Horizontal constraints let horizontalConstraints = NSLayoutConstraint.constraintsWithVisualFormat("H:|[childView]|", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: views) container.addConstraints(horizontalConstraints) //Vertical constraints let verticalConstraints = NSLayoutConstraint.constraintsWithVisualFormat("V:|[childView]|", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: views) container.addConstraints(verticalConstraints) } //Add constraint with top left right bottom is same with option UIEdgeInsets func addChildToContainer(parent container: UIView, child childView: UIView, andInsets insets: UIEdgeInsets) { container.addSubview(childView) let views = Dictionary(dictionaryLiteral: ("childView", childView),("container", container)) //Horizontal constraints let horizontalConstraints = NSLayoutConstraint.constraintsWithVisualFormat("H:|-\(insets.left)-[childView]-\(insets.right)-|", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: views) container.addConstraints(horizontalConstraints) //Vertical constraints let verticalConstraints = NSLayoutConstraint.constraintsWithVisualFormat("V:|-\(insets.top)-[childView]-\(insets.bottom)-|", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: views) container.addConstraints(verticalConstraints) }