0

I've got a simple Text element, here's the code:

Text("W-XYZ LAB IS CARBON NEUTRAL")
    .foregroundColor(.white)
    .frame(width: elementWidth, alignment: .leading)
    .font(.system(size: 25, weight: .bold))
    .padding(.bottom)
    .border(.red)

elementWidth = screen width / 1.25

Take a look at the screenshot below: Screen shot of Text element

The text in the Text view does not take up all the space. The word "CARBON" can fit in the first line of the text view but for some reason it goes to the second line. How can I fix this?

Abdullah Ajmal
  • 431
  • 5
  • 17
  • The default behavior is to avoid having single words in a new line. I think it's not possible to change this in SwiftUI. Maybe you can use a ´UIViewRepresentable´ to implement this behavior or use the ´Introspect´ package to set this. See also: https://stackoverflow.com/questions/46200027/uilabel-wrong-word-wrap-in-ios-11/46897177#46897177 – viedev Feb 15 '23 at 16:58

0 Answers0