Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to apply a matchedGeometryEffect with the given ID.
iOS Swift
Text("Hello") .matchedGeometryEffect(id: [1], in: namespace)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name instead of a string literal.
Omitting the quotes around the ID string.
✗ Incorrect
The matchedGeometryEffect requires an ID string to link views for animation. "animationID" is a clear, valid ID.
2fill in blank
mediumComplete the code to declare a namespace for matchedGeometryEffect.
iOS Swift
@Namespace private var [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a name that conflicts with other variables.
Not declaring the variable as private.
✗ Incorrect
The variable name 'namespace' is commonly used and clear for the @Namespace property wrapper.
3fill in blank
hardFix the error in the matchedGeometryEffect modifier by completing the missing parameter.
iOS Swift
Rectangle() .matchedGeometryEffect(id: "box", in: [1])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a string instead of the namespace variable.
Using an undeclared variable.
✗ Incorrect
The 'in:' parameter expects the namespace variable declared with @Namespace.
4fill in blank
hardFill both blanks to create a matchedGeometryEffect linking two views with the same ID and namespace.
iOS Swift
Text("Start") .matchedGeometryEffect(id: [1], in: [2]) Text("End") .matchedGeometryEffect(id: [1], in: [2])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different IDs for the two views.
Using different namespace variables.
✗ Incorrect
Both views must share the same ID string and namespace variable to animate smoothly.
5fill in blank
hardFill all three blanks to create a matchedGeometryEffect with a custom anchor and isSource flag.
iOS Swift
Circle() .matchedGeometryEffect(id: [1], in: [2], anchor: [3], isSource: false)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using an invalid anchor value.
Passing the ID without quotes.
Using an undeclared namespace variable.
✗ Incorrect
The ID is a string, the namespace is the variable, and the anchor is a valid UnitPoint like .center.