PhaseAnimator without transition between phases

PhaseAnimator seems a good fit to play gifs in SwiftUI:

struct ContentView: View {
    
    let frames = [UIImage(named: "frame-1")!, UIImage(named: "frame-2")!]
    
    var body: some View {
        PhaseAnimator(frames.indices) { index in
            Image(uiImage: frames[index])
        }
    }
}

The problem is that by default, there's an opacity transition between phases. So I tried using transition(.identity):

Image(uiImage: gif[index])
    .transition(.identity)
    .id(index)

It doesn't work. It stays frozen on the first frame.

It does work if I set the transition to a small offset value:

Image(uiImage: gif[index])
    .transition(.offset(x: 0, y: 0.1))
    .id(index)

It does feel a bit hacky, though.

Is this the expected behavior for .transition(.identity), or is it a bug?

my reading of TransitionPhase.identity is what you have described is expected behavior. And, I expect your idea of using a very small offset is a reasonable workaround since the other possible TransitionPhase don't seem to offer any alternative. Possibly you could write a custom transition to do the job, but I think it would make sense for a separate TransitionPhase for the case you have described.

If you'd like us to consider adding the support for your use case, please file an enhancement request using the Feedback Assistant. If you file the request, please post the Feedback number here so we can make sure it gets routed to the right team.

If you're not familiar with how to file enhancement requests, take a look at Bug Reporting: How and Why?

PhaseAnimator without transition between phases
 
 
Q