Is there a solution to this? I would have thought it would be a common desire. The default white spacing really is bad.
Post
Replies
Boosts
Views
Activity
@DTS Engineer
I am using the new Tab API
struct RoutingUIView: View {
var body: some View {
TabView {
Tab("Posts", systemImage: "square.fill.text.grid.1x2") {
MailView()
}
Tab("Settings", systemImage: "gearshape") {
SettingsView()
}
}
}
}
struct MailView: View {
var body: some View {
NavigationStack {
List {
NavigationLink("An important post...") {
Text("Lorem ipsum.")
.toolbar(.hidden, for: .tabBar)
}
}
.navigationTitle("Posts")
}
}
}
So this more effectively achieved what I wanted, but again as a newbie to SwiftUI coming from CSS, it feels far from intuitive and bizarre that I have to specify the aspectRatio modifier twice:
Image(.personsmiling)
.resizable()
.aspectRatio(contentMode: .fill)
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity)
.aspectRatio(1/1, contentMode: .fill)
.clipped()
I managed to work out a solution. It is crazy to me that the solution is this indirect and complex and unintuitive.
Color.red
.aspectRatio(1, contentMode: .fill)
.overlay {
Image(.liberaltears)
.resizable()
.scaledToFill()
}
.clipped()
.padding()