@DTS Engineer – This doesn't work, I'm afraid. Adding the .aspectRatio(1.0, contentMode: .fill) makes no difference – I assume because we're doing .scaledToFill() before, which is the same as doing .aspectRatio(nil, contentMode: .fill)
Post
Replies
Boosts
Views
Activity
@DTS Engineer – Thanks for the response. I had considered those options but weren't ideal.
I found a slightly better approach, though.
As the expected behaviour is to fill all the available space with the image, we can just use Color (which, when used as a view, expands to fill all the space it is given) and the Image as an overlay.
This will effectively make the Image expand to use all the available space whilst clipping it to its bounds.
Color.clear
.overlay {
Image("adriana-wide")
.resizable()
.scaledToFill()
}
Not quite the solution I was expecting, but does the trick.