As you can see in the screenshot, the button height does not adjust to fit the text size, making it look ugly. How can I increase the hight of the buttons, so it does not look stupid. My question is, how do I increase the height of buttons in SwiftUI? I am trying to make the titlescreen of my Minecraft-like game.
struct ContentView: View {
var body: some View {
GeometryReader { geometry in
VStack (spacing: 8) {
Text("[Name not disclosed]Craft").font(.system(size: geometry.size.width/8))
Button(action: {
}) {
Text("Singleplayer").font(.system(size: geometry.size.width/20))
.frame(minWidth: geometry.size.width/2)
}
Button(action: {
}) {
Text("Multiplayer").font(.system(size: geometry.size.width/20))
.frame(minWidth: geometry.size.width/2)
}
HStack (spacing: 8) {
Button(action: {
}) {
Text("Options").font(.system(size: geometry.size.width/20))
.frame(minWidth: (geometry.size.width/4)-16)
}
Button(action: {
exit(EXIT_SUCCESS);
}) {
Text("Quit Game").font(.system(size: geometry.size.width/20))
.frame(minWidth: (geometry.size.width/4)-16)
}
}
}
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…