どういうことか
.padding()
の書く位置によって表示が変わる!
どうなるのか
Button(action: {
print("押された")
}){
Text("ボタン")
.fontWeight(.bold)
.font(.system(size: 20))
.foregroundColor(Color.white)
.background(Color.blue)
.frame(maxWidth: .infinity, minHeight: 48)
.padding(.horizontal, 32)
}
これだとこう
ちょっと見づらいが、想定通り画面端からの padding
が効いている。
ところが
Button(action: {
print("押された")
}){
Text("ボタン")
.fontWeight(.bold)
.font(.system(size: 20))
.foregroundColor(Color.white)
.background(Color.blue)
.padding(.horizontal, 32)
.frame(maxWidth: .infinity, minHeight: 48)
}
frame
の後ではなく前に書くと効かなくなってしまう。なんてことだ。
で、 padding
だけじゃなくて cornerRadius
とかも場所で効いたり効かなかったりが変わるっぽい。気をつけよう。