Swift HStack サイズを余白いっぱいにするサンプル
環境
Swift version 5.2.3 (swift-5.2.3-RELEASE)
構文
.frame(
maxWidth: .infinity,
maxHeight: .infinity
)
HStackのサイズを余白いっぱいにするには、frame修飾子を使います。
使用例
struct ContentView: View {
var body: some View {
HStack {
Text("Study")
Text("Skill")
Text("Game")
}
.foregroundColor(.white)
.frame(
maxWidth: .infinity,
maxHeight: .infinity
)
.background(Color.yellow)
}
}
struct ContentView: View {
var body: some View {
HStack {
Text("Study")
Text("Skill")
Text("Game")
}
.foregroundColor(.white)
.frame(
maxWidth: .infinity,
maxHeight: .infinity
)
.background(Color.yellow)
}
}
struct ContentView: View { var body: some View { HStack { Text("Study") Text("Skill") Text("Game") } .foregroundColor(.white) .frame( maxWidth: .infinity, maxHeight: .infinity ) .background(Color.yellow) } }