FlexLayout
FlexLayout copied to clipboard
The correct way to use 'sizeThatFits(_:)'
I usually use method #1 when I want to calculate the size of a view with a fixed width and maximum height, just like a 'UILabel'. However, when I tried to do this in flexlayout, the only thing that worked was CGFloat.nan. Am I doing something wrong? If not, I think I need to modify the logic in the library.
혹시 방법을 알고 계시다면 도움 부탁드립니다. @OhKanghoon
yoga 에서는 제약사항에 대한 판단을 YGUndefined 타입으로 하고 있어요. Swift 의 경우.nan 에 해당됩니다.
제약 없이 높이를 계산하고 싶다면 작성해주신 3번 방법을 사용해주시면 됩니다.
참고 자료
- https://github.com/facebook/yoga/blob/909e4bea6e6764e4028d5e47b2f67486e6d26c7e/yoga/algorithm/CalculateLayout.cpp#L2339
- https://github.com/facebook/yoga/blob/909e4bea6e6764e4028d5e47b2f67486e6d26c7e/yoga/YGValue.h#L20
The issue appears to be resolved, so I will close it. If you have any additional feedback, please leave a comment!