A new way to animation style UIButton in SwiftUI
IconTransitionKit is a simple icon transition kit that allows you to transition from one shape to another. Create a UIButton with CAShapeLayers. It offers a collection of the most commonly used navigation icons. Feel free to recolor them and customize the forms as you see fit – alter the line spacing, width, and cap.
An icon transition kit is a collection of motion and transition effects for the icons in your app. This library enables you to add eye-catching animations when switching between screens, increasing the overall user experience.

Both ways animated transitions:
- Menu ↔ Arrow
- Menu ↔ Cross
- Cross ↔ Plus
- Plus ↔ Minus
Usage
To run the example project, clone the repo, and open the TBIconTransitionKitExample project.
Add AnimatedButton to your SwiftUI view.
import SwiftUI
import TBIconTransitionKit
struct ContentView: View {
@State private var buttonState: AnimatedButtonState = .menu
var body: some View {
AnimatedButton(state: .menu, configure: { button in
button.backgroundColor = UIColor(hex: .black)
button.lineColor = .white
}, action: { button in
if button.currentState == .menu {
button.animationTransform(to: .arrow)
} else {
button.animationTransform(to: .menu)
}
})
}
}
Customize the design
lineHeight
lineWidth
lineSpacing
lineColor
lineCap
Requirements
- iOS 13 or higher
Installation
TBIconTransitionKit can be installed using Swift Package Manager.
- In Xcode, open your project, and select File > Swift Packages > Add Package Dependency.
- Enter the repository URL https://github.com/AlexeyBelezeko/TBIconTransitionKit and click Next.
- Select the version you’d like to use and click Next.
- Finally, click Finish to add the package to your project.
Author
- AlexeyBelezeko
- Oleg Turbaba
- [ChatGPT]