r/iOSProgramming • u/Gwail_904 • 5h ago
Question MatchedTransition effect
I’m working on an app for my Jellyfin library and I’ve noticed that Apple Music’s opening animation for albums actually feels like the square artwork simply floats to the center. Whereas mine enlarges the square artwork and another copy spawns in the middle then (see also screenshot).
Does Apple use a different thing cause I’m using the regular MatchedTranitionSource effect thing.
Here’s the comparison videos (Mine is the same album as in the screenshot): https://imgur.com/a/sqz4E3D
3
Upvotes
3
u/ThanhDongNguyen 2h ago
I think the difference is that .navigationTransition(.zoom) with matchedTransitionSource doesn't morph your artwork into the artwork in the new view. It zooms the whole destination view out of the source rect. So you see the big image growing, then your real artwork view in the middle, that's the "second copy".
Apple Music feels like the image itself flies to the new position. To get that, do it in one view instead of a push: show the album detail as a ZStack overlay and use matchedGeometryEffect on the artwork, same id and namespace in the grid cell and in the detail header, and change the state inside withAnimation(.spring). The rest of the detail can fade in with a normal transition.
Downside is you lose the NavigationStack back swipe, so you need your own drag to dismiss. If you must keep the push, the way I know is a custom UIViewControllerAnimatedTransitioning in UIKit with a snapshot of the image.