'animation' was deprecated in iOS 15.0

Hmm... I don't quite get it. How can I get rid of the deprecation warning in the following case?

import SwiftUI

struct ContentView: View {
	@State var isAnimating = false
	
    var body: some View {
		Circle()
			.fill(Color.pink)
			.frame(width: 150, height: 150)
			.scaleEffect(isAnimating ? 0.5 : 1.0)
			.animation(Animation.easeIn(duration: 1.0).repeatForever())
			.onAppear {
				self.isAnimating = true
			}
    }
}

The following could work except that I have to tap the circle once.

import SwiftUI

struct ContentView: View {
	@State var isAnimating = true
	
	var body: some View {
		Circle()
			.fill(Color.pink)
			.frame(width: 150, height: 150)
			.scaleEffect(isAnimating ? 1 : 0.5)
			.animation(Animation.easeIn(duration: 3.0).repeatForever(), value: isAnimating)
			.onTapGesture { isAnimating.toggle() }
			.onAppear {
				isAnimating = false
				isAnimating.toggle()
			}
	}
}

Muchos thankos.

Answered by Tomato in 705643022

I guess I've somehow worked it out as follows.

import SwiftUI

struct ContentView5: View {
	@State private var larger = true
	
	var body: some View {
		VStack {
			Circle()
				.fill(Color.pink)
				.frame(width: 150, height: 150)
				.scaleEffect(larger ? 2 : 1)
				.animation(.easeInOut(duration: 1).repeatForever(), value: larger)
				
		}.onAppear {
			larger = false
		}
	}
}
Accepted Answer

I guess I've somehow worked it out as follows.

import SwiftUI

struct ContentView5: View {
	@State private var larger = true
	
	var body: some View {
		VStack {
			Circle()
				.fill(Color.pink)
				.frame(width: 150, height: 150)
				.scaleEffect(larger ? 2 : 1)
				.animation(.easeInOut(duration: 1).repeatForever(), value: larger)
				
		}.onAppear {
			larger = false
		}
	}
}
'animation' was deprecated in iOS 15.0
 
 
Q