Contents

init(subviews:content:)

Creates an instance that uniquely identifies and creates views across updates based on the subviews of a given view.

Declaration

init<V>(subviews view: V, @ViewBuilder content: @escaping (Subview) -> Content) where Data == ForEachSubviewCollection<Content>, ID == Subview.ID, Content : View, V : View

Parameters

  • view:

    The view to extract the subviews of.

  • content:

    The view builder that creates views from subviews.

Discussion

Subviews are proxies to the resolved view they represent, meaning that modifiers applied to the original view will be applied before modifiers applied to the subview, and the view is resolved using the environment of its container, not the environment of the its subview proxy. Additionally, because subviews must represent a single leaf view, or container, a subview may represent a view after the application of styles. As such, attempting to apply a style to it may have no effect.