ios – SwiftUI. Find out how to clear out ViewBuilder childs?


I’m very curios how .swipeActions of List view implemented

This is how .swipeActions looks like

List {
        Text("Test")
            .swipeActions {
                Button("Action1") {}
                Button("Action2") {}
            }
    }

.swipeActions accepts ViewBuilder as a content

The interesting part is If I add anything else then Button, it will be ignored.

List {
        Text("Test")
            .swipeActions {
                Button("Action1") {}
                Text("Test")
                Button("Action2") {}
            }
    }

Text is ignored here !

How to achieve this ?

I want to make custom View with similar functionality.

How to create ViewModifier that takes ViewBuilder as parameter and then filter everything except Button ?

Leave a Reply

Your email address will not be published. Required fields are marked *