Skip to content

Instantly share code, notes, and snippets.

@Edudjr
Created October 23, 2022 23:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Edudjr/81ca1e266427857ee656806edc5ada30 to your computer and use it in GitHub Desktop.
Save Edudjr/81ca1e266427857ee656806edc5ada30 to your computer and use it in GitHub Desktop.
extension View {
func animate(duration: CGFloat, _ execute: @escaping () -> Void) async {
await withCheckedContinuation { continuation in
withAnimation(.linear(duration: duration)) {
execute()
}
DispatchQueue.main.asyncAfter(deadline: .now() + duration) {
continuation.resume()
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment