0

I have a problem with SwiftUI animation of a Button label. The problem is that after I change the 'Button Shapes' accessibility setting from the iOS settings menu (Settings->Accessibility->Display & Text Size->Button Shapes), the animation stops working until I kill the application and start it again.

For example and proof, I add the following code:

import SwiftUI

struct ContentView: View {
    @State private var animAmount = 1.0
    
    var body: some View {
        VStack {
            Button(action: {
                print("Button tapped.")
            }, label: {
                Image(systemName: "globe")
                    .resizable()
                    .scaledToFit()
                    .frame(width : 200)
                    .foregroundColor(.accentColor)
                    .scaleEffect(animAmount)
                    .onAppear {
                        let baseAnimation = Animation.easeOut(duration: 1.5)
                        let repeated = baseAnimation.repeatForever(autoreverses: true)
                        
                        withAnimation(repeated) {
                            animAmount = 1.5
                        }
                    }
            })
            .padding()
        }
    }
}
ihmgsm
  • 23
  • 6

0 Answers0