import SwiftUI
struct ContentView: View {
@State var count = 1
var body: some View {
VStack(alignment: .center) {
Text("Count")
.font(.title)
.background(Color.white)
Text("\(count)")
.font(.system(size: 64))
.background(Color.white)
.padding(16)
Spacer()
Button(action: {
self.count += 1
}, label: {
Text("Click")
.font(.system(size: 32))
.foregroundColor(Color.white)
.background(Color.gray)
.padding(16)
.frame(minWidth: 0, maxWidth: .infinity)
})
.background(Color.blue)
.padding(16)
}
.background(Color.red)
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
- VStackのWidthは子のサイズに影響されていそう
- Buttonのタップ領域はTextに指定した横幅
- ButtonのWidthはTextに指定した横幅に影響されてそう
- ButtonのWidthを設定するだけだとタップ領域は広がらない
- paddingは他のViewとの距離