21

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.

4
  • 3
    I assume the answer in the following post will be helpful. Commented Dec 15, 2019 at 15:17
  • Ok. I'll check. Thanks Commented Dec 15, 2019 at 18:37
  • 1
    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 :-) Commented Dec 15, 2019 at 18:42
  • Cool. If it was helpful you can just vote up in that post. )) Commented Dec 16, 2019 at 5:51

1 Answer 1

35

Thanks to Asperi to point me into the right direction.

I just had to add

.buttonStyle(PlainButtonStyle()) 

to the group.

Sign up to request clarification or add additional context in comments.

2 Comments

why does this make the button unclickable?
may be adding a contentShape modifier would help ?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.