Skip to content

ahmetbostanciklioglu/AnimatableMacroSwiftUI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

🎬 Animatable Macro in SwiftUI

A minimal example of animating a custom Shape with SwiftUI's @Animatable macro

Platform iOS Swift SwiftUI Xcode Stars Last Commit

📖 Overview

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.

✨ Features

  • Custom CircleShape that draws an arc via Path.addArc(...).
  • @Animatable macro applied to the shape so its radius interpolates during animation.
  • Tap-to-toggle interaction using .onTapGesture wrapped in withAnimation(.smooth).
  • .contentShape(.rect) demonstrating a tappable area even when the drawn radius is 0.
  • Dark-mode SwiftUI preview for quick iteration in Xcode.

📸 Preview

Collapsed state Expanded state

🚀 Getting Started

git clone https://github.com/ahmetbostanciklioglu/AnimatableMacroSwiftUI.git
cd AnimatableMacroSwiftUI
open AnimatableMacroSwiftUI.xcodeproj

Open the project in Xcode and press ⌘R to build and run it on a simulator or device.

📋 Requirements

  • 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.

🧑‍💻 Author

Ahmet Bostancıklıoğlu@ahmetbostanciklioglu · ahmetbostancikli@gmail.com

⭐ If this helped you, consider giving the repo a star!

About

A minimal SwiftUI example animating a custom Shape's radius with the @Animatable macro.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages