0
0

More than 1 year has passed since last update.

SwiftUI List中のButtonのタッチ範囲を変更する。

Posted at

listのrowにbuttonを配置しているとき、rowのbutton以外をタッチして反応され困っていた。
特にlist全体に.onTapGesture {}属性をつけていると、干渉がひどかった。

.buttonStyle(PlainButtonStyle())

このmodifierをButtonにつけると、タッチ範囲がrow全体ではなく、button部分のみになる。

例:

  FavoriteButton(isSet: $liked)
                .buttonStyle(PlainButtonStyle())

参考:
https://stackoverflow.com/questions/63087817/strange-buttons-behaviour-in-a-list-swiftui

0
0
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
0
0