> For the complete documentation index, see [llms.txt](https://lochiwei.gitbook.io/ios/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lochiwei.gitbook.io/ios/swiftui/anim/animatable/animatable-modifiers.md).

# Animatable Modifiers

[SwiftUI](/ios/swiftui.md) ⟩ [Animations](/ios/swiftui/anim.md) ⟩ [Animatable](/ios/swiftui/anim/animatable.md) ⟩ [Modifiers](/ios/swiftui/anim/animatable/animatable-modifiers.md) ⟩&#x20;

{% hint style="danger" %} <mark style="color:purple;">AnimatableModifier</mark> <mark style="color:red;">**deprecated**</mark>:

```swift
// use `ViewModifier`, `Animatable` instead:
struct MyAnimatableModifier: ViewModifier, Animatable {
  // ⭐️ Animatable
  var animatableData: CGFloat { ... }
  // ⭐️ ViewModifier
  func body(content: Content) -> some View { ... }
}
```

{% endhint %}

{% tabs %}
{% tab title="⭐️ 重點" %}
{% hint style="success" %}
To examine how SwiftUI **interpolates** between diﬀerent values during an **animation**, we can add **log statements** to the <mark style="color:red;">**setter**</mark> of [animatableData](https://developer.apple.com/documentation/swiftui/animatable/animatabledata-swift.property-6nydg) or the <mark style="color:red;">**body**</mark> method of the [animatable modiﬁer](/ios/swiftui/anim/animatable/animatable-modifiers.md).
{% endhint %}
{% endtab %}

{% tab title="💈範例" %}

* [.tapToShake()](/ios/swiftui/anim/animatable/animatable-modifiers/.taptoshake.md)
  {% endtab %}

{% tab title="📗 參考" %}

* [ ] Thinking in SwiftUI, Ch. 6: Animations - Custom Animations (p.123)
* [ ] 5 Stars ⟩ [What's new in Xcode 13 beta 5](https://www.fivestars.blog/articles/xcode-13-beta-5/) - AnimatableModifier deprecated.
* [ ] Paul ⟩ [What’s new in SwiftUI for iOS 15 ](https://www.hackingwithswift.com/articles/235/whats-new-in-swiftui-for-ios-15)- .animation(\_:) deprecated.
  {% endtab %}

{% tab title="📘 手冊" %}

* [SwiftUI](https://developer.apple.com/documentation/swiftui) ⟩&#x20;
  * [Animations](https://developer.apple.com/documentation/swiftui/animations) ⟩ [AnimatableModifier](https://developer.apple.com/documentation/swiftui/animatablemodifier) ( <mark style="color:red;background-color:yellow;">**deprecated**</mark> )
  * [View](https://developer.apple.com/documentation/swiftui/view) ⟩ [Deprecated Modifiers](https://developer.apple.com/documentation/swiftui/view-deprecated)
    {% endtab %}

{% tab title="🗣 討論" %}

* [AnimatableModifier is now deprecated, how to "use Animatable directly"?](https://stackoverflow.com/questions/70805114/swiftuis-animatablemodifier-is-now-deprecated-but-how-to-use-animatable-direc)
* [How to replace deprecated .animation() in SwiftUI?](https://stackoverflow.com/questions/69443588/how-to-replace-deprecated-animation-in-swiftui)
  {% endtab %}

{% tab title="👥 相關" %}

* is [Animatable](/ios/swiftui/anim/animatable.md) [ViewModifier](/ios/swiftui/view/modifier/viewmodifier.md).
  {% endtab %}
  {% endtabs %}
