SwiftUI and AnyView: Performance benchmarks

@sveinhal Thank you! Approached from that angle it makes perfect sense. You also don't know, for example, if AnyView is wrapping a Section.

That also explains how simply wrapping the AnyView in a VStack restores performance. If the outermost view is a VStack then each "row" is still just one view.

As an aside, one should note that, as of iOS 16, List is backed up by UICollectionView and not UITableView.

I wrote an article a couple of years ago on Deep Inside Views, State and Performance in SwiftUI and in it I mentioned how SwfitUI uses type information such as this to build out a UINavigationView structure before it even evaluates the view body containing the NavigationView view.

This would appear to be more of the same.

5 Likes