I am working on SwiftUI to make a widget and I can't figure out if I'm doing something wrong or there's a bug in SwiftUI.
I have an Image that I use as a background and at the top there's a text. If I apply resizable() to the Image it also affects the behaviour of the text.
The following code
Creates a full background image that takes the whole view, but the Text is out of bounds as well.
And the following code (without resizable()):
Creates the Image without filling the whole space but the Text is perfectly displayed.
(I would have attached screenshots but it doesn't seem possible)
I have an Image that I use as a background and at the top there's a text. If I apply resizable() to the Image it also affects the behaviour of the text.
The following code
Code Block var body: some View { ZStack { VStack { Image(affirmation.customImageName ?? "c_0") .resizable() .scaledToFill() .clipped() } HStack { Text(affirmation.title) .font(.body) .multilineTextAlignment(.leading) .lineLimit(nil) Spacer() } .padding(.leading, 5) .padding(.top, 5) } }
Creates a full background image that takes the whole view, but the Text is out of bounds as well.
And the following code (without resizable()):
Code Block var body: some View { ZStack { VStack { Image(affirmation.customImageName ?? "c_0") .scaledToFill() .clipped() } HStack { Text(affirmation.title) .font(.body) .multilineTextAlignment(.leading) .lineLimit(nil) Spacer() } .padding(.leading, 5) .padding(.top, 5) } }
Creates the Image without filling the whole space but the Text is perfectly displayed.
(I would have attached screenshots but it doesn't seem possible)