I know it's possible to set the line limit to nil, enabling a text view to grow, but is it possible to disable truncation completely? In some odd text wrapping situations, it seems the views still prefer to truncate rather than grow an additional line, especially in cases where only a partial word would wrap.
Possible to disable truncation on Text or TextField views?
i came here looking for the answer to the same question, and was disappointed to see no replies. however, it occurred to me to try something which turned out to work, at least in my case: try setting the frame max-height of the text to infinity, e.g.:
Text("your really long bit of text that was truncating instead of wrapping, etc.")
.lineLimit(nil)
.frame(maxHeight: .infinity)
hope it works for you too!
[ later edit: although this technique does prevent truncation, it also can sometimes inexplicably make what should be a single line of text be displayed with an excessive amount of vertical padding. i've noticed this primarily with japanese text, although i doubt there's a connection. no workaround as yet ... ]
[ still later ... turns out you can sort of work around the issue by wrapping your text in, say, a vstack, and putting the frame modifier on that, e.g.:
VStack(alignment: .leading, spacing: 0.0) {
Text(name)
PlaceCartouche(addr, size: 14.0)
}
.frame(maxHeight: .infinity)
in my code, the text inside the placecartouche container was having the wrapping problem. applying the frame modifier to the styled text inside that container behaved oddly, but the additional level of abstraction seems to fix it ... ]
You can try this
Text("your really long bit of text that was truncating instead of wrapping, etc.")
.lineLimit(1)
.minimumScaleFactor(0.5)
Same works with TextField