Contents

tipAnchor(_:)

Sets a value for the specified tip anchor to be used to anchor a tip view to the .bounds of the view.

Declaration

nonisolated func tipAnchor<AnchorID>(_ id: AnchorID) -> some View where AnchorID : Hashable, AnchorID : Sendable

Parameters

  • id:

    The anchored view’s identifier.

Return Value

A new version of the view that writes to the key.

Discussion

Use this modifier to specify an anchor view for a TipView’s arrow to point towards.

struct TrailRow: View {
    let trail: Trail

    var body: some View {
        HStack {
            Text(trail.name)

            Button(action: trail.favorite) {
                Image(systemName: "star")
            }
            .tipAnchor("FavoriteTrailTipAnchor")
        }

        TipView(FavoriteTrailTip(), anchorID: "FavoriteTrailTipAnchor")
    }
}