8
votes

I want to create a game menu which shows a list of different options like 'New Game'.

I've realised that with buttons:

    var body: some View {
        VStack {
            Image("Title")
            Group {
                Button(LocalizedStringKey("new"), action: {}
                Button(LocalizedStringKey("load"), action: {})
                Button(LocalizedStringKey("save"), action: {})
                Button(LocalizedStringKey("resume"), action: {})
                Button(LocalizedStringKey("main"), action: {})
                Button(LocalizedStringKey("tutorial"), action: {})
                Button(LocalizedStringKey("credits"), action: {})                         
            }
            .background(Color.clear)
            .font(.custom("Snell Roundhand", size: 24))
            .padding()
        }
    }

and it looks like this: enter image description here

How can I hide the background rectangle of the button? I want to see only the text. Touching the text should trigger the action.

1
I assume the answer in the following post will be helpful. - Asperi
Ok. I'll check. Thanks - Stefan
Yes. that was the solution: I just had to add ".buttonStyle(PlainButtonStyle())". If you want to get the credits for this, you can post it as answer :-) - Stefan
Cool. If it was helpful you can just vote up in that post. )) - Asperi

1 Answers

11
votes

Thanks to Asperi to point me into the right direction.

I just had to add

.buttonStyle(PlainButtonStyle())

to the group.