easeInOut
An animation that combines the behaviors of in and out easing animations.
Declaration
static var easeInOut: Animation { get }Return Value
An ease-in ease-out animation with the default duration.
Discussion
An easing animation provides motion with a natural feel by varying the acceleration and deceleration of the animation, which matches how things tend to move in reality. An ease in and out animation starts slowly, increasing its speed towards the halfway point, and finally decreasing the speed towards the end of the animation.
The easeInOut animation has a default duration of 0.35 seconds. To specify the duration, use the easeInOut(duration:) method.
The following code shows an example of animating the size changes of a Circle using an ease in and out animation.
struct ContentView: View {
@State private var scale = 0.5
var body: some View {
VStack {
Circle()
.scale(scale)
.animation(.easeInOut, value: scale)
HStack {
Button("+") { scale += 0.1 }
Button("-") { scale -= 0.1 }
}
}
}
}