A minimal example of animating a custom Shape with SwiftUI's @Animatable macro
AnimatableMacroSwiftUI is a concise learning example that shows how the @Animatable macro makes a custom SwiftUI Shape animate its stored properties automatically. A CircleShape draws an arc whose radius is marked as animatable, so tapping the view smoothly grows the circle from 0 to 100 and back. The macro removes the boilerplate of manually conforming to Animatable and implementing animatableData.
- Custom
CircleShapethat draws an arc viaPath.addArc(...). @Animatablemacro applied to the shape so itsradiusinterpolates during animation.- Tap-to-toggle interaction using
.onTapGesturewrapped inwithAnimation(.smooth). .contentShape(.rect)demonstrating a tappable area even when the drawn radius is0.- Dark-mode SwiftUI preview for quick iteration in Xcode.
git clone https://github.com/ahmetbostanciklioglu/AnimatableMacroSwiftUI.git
cd AnimatableMacroSwiftUI
open AnimatableMacroSwiftUI.xcodeprojOpen the project in Xcode and press ⌘R to build and run it on a simulator or device.
- iOS 26.1 or later
- Xcode 26
- Swift 5.0+
The @Animatable macro is part of modern SwiftUI, so a recent Xcode/SDK toolchain is required.
Ahmet Bostancıklıoğlu — @ahmetbostanciklioglu · ahmetbostancikli@gmail.com
⭐ If this helped you, consider giving the repo a star!

