Steven-Carrot
Steven-Carrot

Reputation: 3051

How to make animation slower SwiftUI

    Button("forward") {
        withAnimation(.easeInOut.delay(1)) {
            isForward.toggle()
        }
    }

I tried to make my animation slower and smoother however the result i got is freezed animation.

My second try was lowering down the delay value to 0.7 but it did not work too.

Upvotes: 1

Views: 1466

Answers (2)

Asperi
Asperi

Reputation: 257533

I think you just wanted to change duration

Button("forward") {
    withAnimation(.easeInOut(duration: 1)) {   // << here !!
        isForward.toggle()
    }
}

Upvotes: 1

Steven-Carrot
Steven-Carrot

Reputation: 3051

Change from .delay to .speed instead. Lower value = slower speed.

withAnimation(.easeInOut.speed(0.5)) {
        isForward.toggle()
}

Upvotes: 2

Related Questions