LoginSignup
1
1

More than 1 year has passed since last update.

SwiftUI Buttonタップ時にハイライトをさせないようにしたい

Posted at

configuration.labelだけのButtonStyleを作り

struct NotHighlightButtonStyle: ButtonStyle {
    func makeBody(configuration: Configuration) -> some View {
        configuration.label
    }
}

buttonStyleに定義すればボタンタップ時にハイライトしないようにできる。

struct ContentView: View {
    var body: some View {
        Button {
            print("tap!")
        } label: {
            //~~省略
        }.buttonStyle(NotHighlightButtonStyle())
    }
}

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1