Posts

Post not yet marked as solved
3 Replies
462 Views
I am aiming to achieve a callback when an animation of offset change is finished. So, I found a workaround online which uses the AnimatableModifier to check when the animatableData equals the target value. But it turns out AnimatableModifier is now deprecated. And I cannot find an alternative to it. I am aware that GeometryEffect will work for this case of offset change, where you could use ProjectionTransform to do the trick. But I am more concerned about the official recommendation to "use Animatable directly". Seriously, the only tutorial about the Animatable protocol I can find online is examples of using the Shape struct which implicitly implements the Animatable protocol. And the following code I improvised with the Animatable protocol doesn't even do the "animating". Thanks for your kind reading, and maybe oncoming answers!
Posted
by gwozi.
Last updated
.
Post not yet marked as solved
1 Replies
754 Views
As shown in the gif below, the second tap on the purple rectangle does not trigger the animation for the blue rectangle to fade in. Is this a Bug or an obscure Feature? Thanks for your kind reply! trying to toggle the opacity of the big blue rectangle with animation: https://i.stack.imgur.com/teMq3.gif struct FadeTestView: View {  @State var fade: Bool = false  var body: some View {   VStack{    Rectangle().fill(.blue).frame(width: 100, height: 100, alignment: .center)     .opacity(fade ? 0 : 1)         Button(action: {     withAnimation(.easeInOut(duration: 2)){ fade.toggle() }    }){     Circle().fill(.yellow).frame(width: 50, height: 50, alignment: .center)    }         Rectangle().fill(.purple).frame(width: 50, height: 50, alignment: .center)     .gesture(TapGesture().onEnded{      withAnimation(.easeInOut(duration: 2)){ fade.toggle() }     })   }  } }
Posted
by gwozi.
Last updated
.