Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding more than 5 views in the constrain closure #263

Open
ghost opened this issue Sep 21, 2017 · 3 comments
Open

adding more than 5 views in the constrain closure #263

ghost opened this issue Sep 21, 2017 · 3 comments

Comments

@ghost
Copy link

ghost commented Sep 21, 2017

how can i add more than 5 views in the constrain

@bryanjclark
Copy link

@pprevalon To ad more than 5, you can pass in an array of objects, and then unpack that array inside the closure. Here's an extreme example from the KA app:

constrain([container, googleButton, facebookButton, orLabel, textBackground, textSeparator, usernameField, passwordField, forgotButton, passwordManagerLoginButton, signInButton, errorLabel]) { proxies in
			let (container, googleButton, facebookButton, orLabel, textBackground, textSeparator, usernameField, passwordField, forgotButton, passwordManagerLoginButton, signInButton, errorLabel) = (proxies[0], proxies[1], proxies[2], proxies[3], proxies[4], proxies[5], proxies[6], proxies[7], proxies[8], proxies[9], proxies[10], proxies[11])
			let itemWidth: CGFloat = 256
			let itemHeight: CGFloat = 48
			let buttonSpacing = SignInDefaultView.buttonSpacing
			let forgotButtonMargin: CGFloat = 14

			errorLabel.centerX == container.centerX
			errorLabel.width == itemWidth
			errorLabel.bottom == googleButton.top - buttonSpacing

			googleButton.centerX == container.centerX
			googleButton.width == itemWidth
			googleButton.height == itemHeight

                        // etc
}

@bryanjclark
Copy link

See also the discussion over here: #197

@ghost
Copy link
Author

ghost commented Oct 29, 2017

Thank you a million

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant