MatchedGeometryEffect Matches Without Source (FIXED!)

If two views have a call to matchedGeometryEffect, with the same id and namespace, and both calls have isSource = false, the views SHOULD NOT match. However, the framework picks one of the views to act as source and the match occurs.

Bug Report: FB7968204

Workaround: No, use a combination of id and namespace not currently in use.

Last Version Checked: Xcode 12, Beta 4. Fixed in Beta 4!

Sample Code

struct ExampleView1: View {
    @Namespace var ns
    
    var body: some View {
        HStack {
            Rectangle().foregroundColor(Color.blue)
                .matchedGeometryEffect(id: "id1", in: ns, isSource: false)
                .frame(width: 100, height: 100)
            
            Circle().foregroundColor(Color.green)
                .matchedGeometryEffect(id: "id1", in: ns, isSource: false)
                .frame(width: 100, height: 100)
        }
    }
}

This is the outcome:

Leave a Comment

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close