You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using a LazyHStack containing Text views of various lengths, some short, some intended to wrap to multiple lines.
One of the not-well-documented features of LazyHStack is that it sets its height based on the visible items, and then proposes that height to future lazily instantiated items. So, if the first few items are just one line long, any subsequent multi-line Text will accept the LazyHStack's proposed height and truncate with an ellipsis rather than wrap to multiple lines.
As far as I know, the way to fix this is to calculate how much space I would need for multiple lines of text, and pass that in a .frame to my Text. In my experience, that means messing around with UIKit (UIFont, UIFontMetrics), to ask what the height of N lines of text would be, including line spacing (leading). It might be influenced by the user's choice of dynamic font sizes, so I can't hard code it.
I can't use UIFont/UIFontMetrics in Skip, right? What's the right way to pre-compute the height of N lines for a frame?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using a LazyHStack containing Text views of various lengths, some short, some intended to wrap to multiple lines.
One of the not-well-documented features of LazyHStack is that it sets its height based on the visible items, and then proposes that height to future lazily instantiated items. So, if the first few items are just one line long, any subsequent multi-line Text will accept the LazyHStack's proposed height and truncate with an ellipsis rather than wrap to multiple lines.
As far as I know, the way to fix this is to calculate how much space I would need for multiple lines of text, and pass that in a
.frame
to my Text. In my experience, that means messing around with UIKit (UIFont, UIFontMetrics), to ask what the height of N lines of text would be, including line spacing (leading). It might be influenced by the user's choice of dynamic font sizes, so I can't hard code it.I can't use UIFont/UIFontMetrics in Skip, right? What's the right way to pre-compute the height of N lines for a frame?
Beta Was this translation helpful? Give feedback.
All reactions