Post

Replies

Boosts

Views

Activity

Reply to The Slider value doesn't connect to the animation
Basically, it is SwiftUI code. Those were the most necessary parts of the code.As requested, here is the entire ContentView.swift file:import SwiftUI struct ContentView: View { @State private var animationAmount: CGFloat = 1 @State private var stiffnessAmount: CGFloat = 1 @State private var animationCount: CGFloat = 1 var body: some View { VStack{ HStack{ Slider(value: $stiffnessAmount, in: 1...10, step: 1) Text("Stiffness: \(stiffnessAmount)") } HStack{ Slider(value: $animationCount, in: 1...5, step: 1) Text("Animation Count: \(animationCount)") } Text("Look here!") .font(.title) .frame(width: 1000, height: 1000, alignment: .center) .background(Color.red) .foregroundColor(.black) .clipShape(Circle()) .scaleEffect(animationAmount) .animation( Animation.interpolatingSpring(stiffness: Double(stiffnessAmount), damping: 0) //.repeatForever(autoreverses: false) .repeatCount(Int(animationCount), autoreverses: false) ) .onAppear{ self.animationAmount = 0.5 } } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } }
May ’20