{"action":"created","issue":{"url":"https://api.github.com/repos/SnapKit/Masonry/issues/261","labels_url":"https://api.github.com/repos/SnapKit/Masonry/issues/261/labels{/name}","comments_url":"https://api.github.com/repos/SnapKit/Masonry/issues/261/comments","events_url":"https://api.github.com/repos/SnapKit/Masonry/issues/261/events","html_url":"https://github.com/SnapKit/Masonry/pull/261","id":113732181,"number":261,"title":"Add mas_replaceConstraints method to View-MASAdditions","user":{"login":"dourgulf","id":1005591,"avatar_url":"https://avatars.githubusercontent.com/u/1005591?v=3","gravatar_id":"","url":"https://api.github.com/users/dourgulf","html_url":"https://github.com/dourgulf","followers_url":"https://api.github.com/users/dourgulf/followers","following_url":"https://api.github.com/users/dourgulf/following{/other_user}","gists_url":"https://api.github.com/users/dourgulf/gists{/gist_id}","starred_url":"https://api.github.com/users/dourgulf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dourgulf/subscriptions","organizations_url":"https://api.github.com/users/dourgulf/orgs","repos_url":"https://api.github.com/users/dourgulf/repos","events_url":"https://api.github.com/users/dourgulf/events{/privacy}","received_events_url":"https://api.github.com/users/dourgulf/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-10-28T02:47:19Z","updated_at":"2015-11-20T05:59:59Z","closed_at":"2015-11-20T05:59:59Z","pull_request":{"url":"https://api.github.com/repos/SnapKit/Masonry/pulls/261","html_url":"https://github.com/SnapKit/Masonry/pull/261","diff_url":"https://github.com/SnapKit/Masonry/pull/261.diff","patch_url":"https://github.com/SnapKit/Masonry/pull/261.patch"},"body":"Usecase:\r\n\r\nself is the super view\r\n\r\nview constraint like this:\r\n\r\n[[headerView][scrollView]-------]\r\n\r\nInitailly scrollView's tailing equalTo self\r\n\r\nIf I want to change the scrollView's traling from self to headerView's trailing, I must remember the constraint with a variable, uninstall it and update it.\r\n\r\n```\r\nMASConstraint *scrollViewTrailing;\r\n[scrollView mas_makeConstraints:^(MASConstraintMaker *make) {\r\n    make.leading.equalTo(HeaderView.mas_trailing);\r\n    make.top.equalTo(self);\r\n    make.bottom.equalTo(self);\r\n    scrollViewTrailing = make.trailing.equalTo(self);\r\n}];\r\n\r\n// change constraint:\r\n[scrollViewTrailing uninstall];\r\n[scrollView mas_updateConstraints:^(MASConstraintMaker *make) {\r\n\tCGRect frame = scrollView.frame;\r\n    if (frame.size.width <= 0) {\r\n    \t// make width full\r\n        scrollViewTrailing = make.trailing.equalTo(self);\r\n    }\r\n    else {\r\n    \t// make width to zero\r\n        scrollViewTrailing = make.trailing.equalTo(HeaderView.mas_trailing);\r\n    }\r\n}];\r\n```\r\n============================================================\r\nIf add a replaceConstraints method, we can do it directly no additional variable anymore.\r\n\r\n```\r\n[scrollView mas_makeConstraints:^(MASConstraintMaker *make) {\r\n    make.leading.equalTo(HeaderView.mas_trailing);\r\n    make.top.equalTo(self);\r\n    make.bottom.equalTo(self);\r\n    make.trailing.equalTo(self);\r\n}];\r\n// change constraint:\r\n[scrollView mas_replaceConstraints:^(MASConstraintMaker *make) {\r\n\tCGRect frame = scrollView.frame;\r\n    if (frame.size.width <= 0) {\r\n    \t// make width full\r\n        make.trailing.equalTo(self);\r\n    }\r\n    else {\r\n    \t// make width to zero\r\n        make.trailing.equalTo(HeaderView.mas_trailing);\r\n    }\r\n}];\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/SnapKit/Masonry/issues/comments/158291489","html_url":"https://github.com/SnapKit/Masonry/pull/261#issuecomment-158291489","issue_url":"https://api.github.com/repos/SnapKit/Masonry/issues/261","id":158291489,"user":{"login":"cloudkite","id":598870,"avatar_url":"https://avatars.githubusercontent.com/u/598870?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudkite","html_url":"https://github.com/cloudkite","followers_url":"https://api.github.com/users/cloudkite/followers","following_url":"https://api.github.com/users/cloudkite/following{/other_user}","gists_url":"https://api.github.com/users/cloudkite/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudkite/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudkite/subscriptions","organizations_url":"https://api.github.com/users/cloudkite/orgs","repos_url":"https://api.github.com/users/cloudkite/repos","events_url":"https://api.github.com/users/cloudkite/events{/privacy}","received_events_url":"https://api.github.com/users/cloudkite/received_events","type":"User","site_admin":false},"created_at":"2015-11-20T05:59:59Z","updated_at":"2015-11-20T05:59:59Z","body":"closed due to inactivity, please reopen if you want to discuss further"}}