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

How do I get the fitting size of either TZStackView or the UIStackView? #65

Open
fatuhoku opened this issue Dec 21, 2015 · 2 comments
Open

Comments

@fatuhoku
Copy link

https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIStackView_Class_Reference/ has a section called Positioning and Sizing the Stack View — I don't understand this wording:

  • Along the stack view’s axis, its fitting size is equal to the sum of the sizes of all the arranged views plus the space between views.
  • Perpendicular to the stack view’s axis, its fitting size is equal to the size of the largest arranged view.
  • If the stack view’s layoutMarginsRelativeArrangement property is set to YES, the stack view’s fitting size is increased to include space for the margins.

This fitting size is exactly what I need — how do I get to it?

@fatuhoku
Copy link
Author

When you add subviews to UIStackView, it automatically resizes to accommodate the newcomer. Yet, this is not a change in intrinsic content size. How does TZStackView replicate this behaviour?

@johngibb
Copy link

I believe you're looking for systemLayoutSizeFittingSize.

For example:

let fittingSize = stackView.systemLayoutSizeFittingSize(UILayoutFittingCompressedSize)

See more at https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIView_Class/#//apple_ref/occ/instm/UIView/systemLayoutSizeFittingSize:

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