{"action":"opened","issue":{"url":"https://api.github.com/repos/robb/Cartography/issues/177","labels_url":"https://api.github.com/repos/robb/Cartography/issues/177/labels{/name}","comments_url":"https://api.github.com/repos/robb/Cartography/issues/177/comments","events_url":"https://api.github.com/repos/robb/Cartography/issues/177/events","html_url":"https://github.com/robb/Cartography/issues/177","id":111265330,"number":177,"title":"accept optional views in constrain()","user":{"login":"sealgair","id":450160,"avatar_url":"https://avatars.githubusercontent.com/u/450160?v=3","gravatar_id":"","url":"https://api.github.com/users/sealgair","html_url":"https://github.com/sealgair","followers_url":"https://api.github.com/users/sealgair/followers","following_url":"https://api.github.com/users/sealgair/following{/other_user}","gists_url":"https://api.github.com/users/sealgair/gists{/gist_id}","starred_url":"https://api.github.com/users/sealgair/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sealgair/subscriptions","organizations_url":"https://api.github.com/users/sealgair/orgs","repos_url":"https://api.github.com/users/sealgair/repos","events_url":"https://api.github.com/users/sealgair/events{/privacy}","received_events_url":"https://api.github.com/users/sealgair/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-10-13T20:36:16Z","updated_at":"2015-10-13T20:36:16Z","closed_at":null,"body":"It would make dynamic layouts easier if it were possible to pass optional views to constrain().  That way, more layout could be done inside of the same closure, and could all be assigned to the same ConstraintGroup, so that it could be replaced later.\r\n\r\nExample:\r\n```swift\r\nlet group = ConstraintGroup()\r\nlet view1 = UILabel()\r\nvar view2: UIView?\r\n\r\nconstrain(view1, view2, replace: group) { view1, view2 in \r\n  view1.top == view1.superview!.topMargin\r\n  if let view2 = view2 {\r\n    view2.top == view1.bottom + 10\r\n   view2.bottom == view2.superview!.bottomMargin\r\n  } else {\r\n    view1.bottom == view1.superview!.bottomMargin\r\n  }\r\n}\r\n```"}}