You can add a rotationEffect
and animate it using repeatForever(autoreverses: false)
:
struct ContentView: View {
@State private var degrees: Double = 0
var body: some View {
HStack {
Image(systemName: "heart.fill")
.rotationEffect(Angle(degrees: degrees))
.animation(Animation.linear(duration: 2).repeatForever(autoreverses: false))
}
.onAppear {
degrees = 360
}
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…