matchedGeometryEffect
Defines a group of views with synchronized geometry using an identifier and namespace that you provide.
Declaration
compose().matchedGeometryEffect<ID>({
id: ID,
in: string,
properties?: SwiftUI.MatchedGeometryProperties,
anchor?: SwiftUI.UnitPoint,
isSource?: boolean,
})nonisolated func matchedGeometryEffect<ID>(
id: ID,
in namespace: Namespace.ID,
properties: MatchedGeometryProperties = .frame,
anchor: UnitPoint = .center,
isSource: Bool = true
) -> some View
where ID : HashableParameters
options.id*IDThe identifier, often derived from the identifier of the data being displayed by the view.
options.in*stringoptions.propertiesSwiftUI.MatchedGeometryPropertiesThe properties to copy from the source view.
options.anchorSwiftUI.UnitPointThe relative location in the view used to produce its shared position value.
options.isSourcebooleanTrue if the view should be used as the source of geometry for other views in the group.
Return value
A new view that defines an entry in the global database of views synchronizing their geometry.
Discussion
This method sets the geometry of each view in the group from the
inserted view with isSource = true (known as the "source" view),
updating the values marked by properties.
If inserting a view in the same transaction that another view
with the same key is removed, the system will interpolate their
frame rectangles in window space to make it appear that there
is a single view moving from its old position to its new
position. The usual transition mechanisms define how each of
the two views is rendered during the transition (e.g. fade
in/out, scale, etc), the matchedGeometryEffect() modifier
only arranges for the geometry of the views to be linked, not
their rendering.
If the number of currently-inserted views in the group with
isSource = true is not exactly one results are undefined, due
to it not being clear which is the source view.
See also
More in Animation.
- animationApplies the given animation to all animatable values within the body closure.
- contentTransitionModifies the view to use a given transition as its method of animating changes to the contents of its views.
- glassEffectTransitionAssociates a glass effect transition with any glass effects defined within this view.
- keyframeAnimatorLoops the given keyframes continuously, updating the view using the modifiers you apply in body.
- matchedTransitionSourceIdentifies this view as the source of a navigation transition, such as a zoom transition.
- phaseAnimatorAnimates effects that you apply to a view over a sequence of phases that change continuously.
- scrollTransitionApplies the given transition, animating between the phases of the transition as this view appears and disappears within the visible region of the containing scroll view.
- springLoadingBehaviorSets the spring loading behavior this view.
- transitionAssociates a transition with the view.