Skip to content

Instantly share code, notes, and snippets.

@benigumocom
Last active December 29, 2023 03:35
Show Gist options
  • Save benigumocom/29ed6f0e2cef78502aec8d6e40a72b7d to your computer and use it in GitHub Desktop.
Save benigumocom/29ed6f0e2cef78502aec8d6e40a72b7d to your computer and use it in GitHub Desktop.
【#SwiftUI】レイアウトの調整に View.background(Color.*) が便利だな 👉 https://android.benigumo.com/?p=30338&preview=true
struct ItemRow: View {
var body: some View {
VStack(alignment: .leading) {
Text("ベイスターズ優勝")
.font(.headline)
.background(.white) // *
Text("2023-12-28")
.font(.caption)
.foregroundStyle(.secondary)
.background(.red) // *
}
.background(.blue) // *
.padding()
.background(.yellow) // *
.frame(maxWidth: .infinity, alignment: .leading)
.background(.green) // *
.overlay(
Rectangle()
.stroke(.gray, lineWidth: 0.5)
)
}
}
PlaygroundPage.current.setLiveView(
ItemRow()
.frame(width: 300)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment