SwiftUI has manufactured it pretty effortless for builders to produce a listing look at, identical to a desk view in UIKit. When working with table see in UIKit, you can effortlessly configure a cell’s indicator by environment the accessoryType home. For example, to disable the disclosure indicator, you established the house to .none like this:

In SwiftUI, it appears to be Apple does not present an API to configure the disclosure indicator in the listing view. In this quick tutorial, I will display you a workaround to cover disclosure indicators if you will need to.

Editor’s be aware: If you are new to SwiftUI, you can look at out our sequence of SwiftUI tutorials here.

Let us start off with a easy list see:

If you run the code in the preview pane, you will see the list view showing a list of text items. Tapping any of the items will bring you to the detailed view.

hide-disclosure-indicator-swiftui

As you can see, when adopting NavigationLink, the built-in list view automatically displays a disclosure indicator in each row of data. The question is how you can hide or remove the indicator.

Hiding Disclosure Indicator

Both the List view and NavigationLink do not come with a modifier for you to configure the appearance of the disclosure indicator. To hide the indicator, you can modify the code like below:

The trick is to embed the NavigationLink and Text view in a ZStack. For the navigation link, instead of presenting the Text view, we change it to display an empty view. And, we attach the opacity modifier to NavigationLink and set its value to 0.

If you test the change in the preview, the disclosure indicator should disappear.

swiftui-list-hide-disclosure-indicator

I hope you find this workaround useful. Feel free to leave me a comment if you have any questions.


Founder of AppCoda. Author of multiple iOS programming books including Beginning iOS 13 Programming with Swift and Mastering SwiftUI. iOS App Developer and Blogger. Follow me at Facebook, Twitter and Google+.

Previous articleBrazilian authorities urged to act on WhatsApp privacy update
Next articleHow to Use Technologies to Put together for Travel During the Coronavirus Pandemic