Thread
On Nos, we’re working on making horizontal images display in a certain aspect ratio, like 4:3. We want the image to fill the space available and then be cropped as needed (assuming the original image isn’t 4:3). I couldn’t believe how hard this was to do in SwiftUI, so if you’re doing something like this, here’s what I found after too many hours of reading and experimenting: stackoverflow.com/a/78903559/2030 TLDR? Here’s an example: ``` Image("example") .resizable() .aspectRatio(contentMode: .fill) .frame( minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity ) .aspectRatio(4 / 3, contentMode: .fit) .clipShape(.rect) ``` Want to see it in the Nos codebase? That’s here: github.com/planetary-social/nos/blob/main/Nos/Views/Components/M...