Post

Replies

Boosts

Views

Activity

Reply to Swift UI Button and focus ring
Well my own answer, can be useful for others.I hesitated to use my own button style ... but this is the solution here in my casestruct SimpleButtonStyle: ButtonStyle { func pressColor(isPressed: Bool) -> Color{ if isPressed { return Color.gray } else { return Color.white } } func makeBody(configuration: Self.Configuration) -> some View { configuration.label .padding([.trailing, .leading], 10) .padding([.top, .bottom], 1) .background( RoundedRectangle(cornerRadius: 5) .fill(pressColor(isPressed: configuration.isPressed)) .overlay(RoundedRectangle(cornerRadius: 5) .stroke(lineWidth: 1) .foregroundColor(Color.gray) ) ) } } struct SomeButton : View { var body: some View { HStack{ Button(action: { print("Pressed") }) { Text("Press") } } .buttonStyle(SimpleButtonStyle()) .font(.headline) .padding(.trailing, 10) } }Take care
Mar ’20