2

    Button(action: {
       print("Round Action")
       }) {
       Text("Press")
       .frame(width: 50, height: 50)
       .foregroundColor(Color.black)
       .background(Color.red)
       .clipShape(Circle())
       }
       .background(Color.blue)

I want the actual button to be tappable and not the square blue frame around it, also is there any way we can just get rid of that frame but could still be able to size that button?

Button Image

1

1 Answer 1

3

You need to set .contentShape for your Button, by default it's a Rectangle:

Button(action: {
    print("Round Action")
}) {
    Text("Press")
        .frame(width: 150, height: 150)
        .foregroundColor(Color.black)
        .background(Color.red)
        .clipShape(Circle())
}
.contentShape(Circle()) // <- here
.background(Color.blue)

is there any way we can just get rid of that frame but could still be able to size that button?

You can try to use padding or scaleEffect but frame is the recommended way of changing the width and height of a view.

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.