Filed as FB20766506
I have a very simple use case for a rectangular widget on the iPhone lock screen: One Text element which should fill as much space as possible. However, it only ever does 2 per default and then eclipses the rest of the string.
Three separate Text elements work fine, so does a fixedSize modifier hack (with that even four lines are possible!). Am I completely misunderstanding something or why is this not possible per default? Other apps' widgets like Health do it as well.
My attempt (background added for emphasis)
Health app widget
var body: some View {
VStack(alignment: .leading) {
/// This should span three lines, but only spans 2 which eclipsed text.
Text("This is a very long text which should span multiple lines.")
// .fixedSize(horizontal: false, vertical: true) /// Using this fixes it as well, but that does not seem like a good default solution.
/// Three separate `Text` elements work fine.
// Text("This is a very long")
// Text("text which should")
// Text("span multiple lines.")
}
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading)
.background(Color.black) /// Added for emphasis of the widget frame
}