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

Feature request: stack views of different size #21

Closed
gerchicov-bp opened this issue Apr 17, 2017 · 8 comments
Closed

Feature request: stack views of different size #21

gerchicov-bp opened this issue Apr 17, 2017 · 8 comments

Comments

@gerchicov-bp
Copy link

In my case I have 3 views placed in vertical order. The problem is it is enough hard to setup them because the are all different but must fill the whole space given to them with predefined height proportion.

@roberthein
Copy link
Owner

Hi @gerchicov-bp! If you could post the code here so I can better understand the problem and help you with the solution :)

@gerchicov-bp
Copy link
Author

https://i.stack.imgur.com/ABfHe.png
All the views have constraints: to the left and to the right of superview, to the nearest top and nearest bottom border (sibling or parent). Each view also has a constraint "height=some_number*superview.height".

The result - views save height proportions independently from size and in the same time they fulfill superview.

@roberthein
Copy link
Owner

If I understand the problem correctly, this is what you want:
https://github.com/roberthein/TinyConstraints/blob/master/Example/TinyConstraints/Examples/Advanced.swift#L41
Here I set relation: .equalOrLess for the last constraint in the stack.

Let me know if this fixes your issue. If not please share the code..

@gerchicov-bp
Copy link
Author

NO. In all of your examples the inner views have equal width and height. What if I need for example a stack of views of sizes:

a*b
a*2b
a*3b

where a == superview.width and b + 2b + 3b = superview.height

@roberthein
Copy link
Owner

@gerchicov-bp Check. You want for example:
superview.height(200)
view1.height(to: superview, multiplier: 1/3)
view2.height(to: superview, multiplier: 1/3)
view3.height(to: superview, multiplier: 1/3)
Right?

multiplier is not implemented at this point, but I could add it this week if this is what you need.

@gerchicov-bp
Copy link
Author

If you didn't implement it then I advice you not to do that - if you add constraints inside such views their behaviour becomes unpredictable. Maybe this occurs because of numbers which become decimal

@roberthein
Copy link
Owner

I will try to implement this feature while avoiding unpredictable behaviour and let you know here when I did it.

@roberthein
Copy link
Owner

I just released TinyConstraints 2.1.0 with the multiplier property.

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

2 participants