Hi all,
I’m stuck on a WidgetKit/SwiftUI layout issue.
I have a systemMedium widget that shows a block of text. What I want is simple:
The text should be as large as possible
But it must always fully fit inside the widget
No ellipsis (“…”)
Short text → big font
Longer text → shrink only as much as needed
The problem: when I try to make the font larger, the widget often shows only a couple of words and then “…” (or it looks like it’s truncating/clipping), even though I’m using multiline text (lineLimit(nil) etc.). If I keep a small fixed font size, the entire text shows fine — so the input string isn’t truncated.
I tried a few approaches:
ViewThatFits seeing which font size fits
minimumScaleFactor
Measuring with NSAttributedString.boundingRect + binary search to calculate the biggest font size that should fit
But WidgetKit still behaves inconsistently and I can’t get a reliable “largest size that fits” result.
Is there a recommended, production-safe way to do this in WidgetKit?
Also: can a SwiftUI Text still end up showing “…” in a widget even with .lineLimit(nil) when it’s constrained vertically?
Thanks in advance — any pointers or known patterns would really help.
Selecting any option will automatically load the page