Going by examples we can see that it is possible to animate different properties with different animations. For example:
Button("Tap me") {self.isShowingRed.toggle()}
.frame(width: 200, height: 200)
.background(isShowingRed ? Color.red : Color.blue)
.animation(.easeIn(duration: 2.5))
.clipShape(RoundedRectangle(cornerRadius: isShowingRed ? 50 : 0))
.animation(Animation.easeInOut(duration: 0.1).repeatCount(5))
This code will animate the button background from red to blue in 2.5 seconds, while animating the corner radius from 0 to 50 with 5 repetitions.
The problem appears as soon as the view is embedded:
VStack {
Button("Tap me") {self.isShowingRed.toggle()}
.frame(width: 200, height: 200)
.background(isShowingRed ? Color.red : Color.blue)
.animation(.easeIn(duration: 2.5))
.clipShape(RoundedRectangle(cornerRadius: isShowingRed ? 50 : 0))
.animation(Animation.easeInOut(duration: 0.1).repeatCount(5))
}
}
When the button is embedded only the first animation is used, in this case both the color and the radius will be animated in 2.5 seconds with no repetitions.
Even if I make the button a separate component, the same problem persists.
Am I doing something wrong or is this a SwiftUI bug?
Edit: I'm using Xcode 11.1 and testing on the simulator.