Sometimes you don’t want to show something to the user because it doesn’t bring any value but you want to keep it anyway. In this case, you can add an option to show and hide some views.
In iOS14 there is a new DisclosureGroup that allows you to do it.
First, you need State property to keep if the content is shown.
@State private var shown = false
And create DisclosureGroup that contains more details about something.
DisclosureGroup(“Learn more”, isExpanded: $shown) {
Text(“Very long text… Very long text… Very long text… Very long text… Very long text… Very long text… Very long text… Very long text… Very long text… Very long text… Very long text… Very long text… Very long text… Very long text… Very long text… Very long text… Very long text… Very long text… Very long text… Very long text… Very long text… Very long text… “)
}
.padding()
You can also put Image and other views inside.
Image(systemName: “star”)