3

How can I implement swiftUI animations on a dynamic island icon? I want to do this:

DynamicIsland() { ... } 
compactLeading: {
  Image("my-icon").shineEffect()
} compactTrailing: {
  Image("my-icon")
} 

Where in shine effect I start the animation on onAppear:

func body(content: Content) -> some View {
  content
    .onAppear() { 
      startAnimation()
    }
}

In the main app it works, but in the dynamic island it doesn't.

annaoomph
  • 552
  • 1
  • 4
  • 22

1 Answers1

2

The documentation explicitly states that standard animations don‘t work. You can only animate content-state update using

built-in transitions: opacity, move(edge:), slide, push(from:), or combinations of them. Additionally, request animations for timer text with numericText(countsDown:).

fruitcoder
  • 1,073
  • 8
  • 24
  • How does PixelPal app animate their graphic in dynamic island and live activity? – Vitaly Aug 15 '23 at 02:09
  • It looks like the content state is updated every second or so with different sprites of the pixel pal which makes it seem like it's animated? – fruitcoder Aug 17 '23 at 09:26