小编Ant*_*eza的帖子

Programmatically show swipe actions in SwiftUI

Given:

  1. SectionView as a row representation in a List
  2. Swipe actions associated with this view
  3. Tappable Image as a part of the same view

Required:

Display swipe actions on Image tap, not only using a swipe gesture.

Will be thankful for any clues regarding implementation.

struct SectionView: View {

@ObservedObject var viewModel: SectionVM

var body: some View {
    HStack {
        ...
        Image("iconVerticalDots") 
            .renderingMode(.template)
            .foregroundColor(AppColors.accent.asColor)
            .padding([.vertical, .leading], 4.0)
            .onTapGesture {
                //Show swipe actions
            }
    }
    .swipeActions {
        actions
    }
}

var …
Run Code Online (Sandbox Code Playgroud)

swiftui swiftui-list swiftui-swipeactions

9
推荐指数
0
解决办法
550
查看次数