Introduction to Hero
Hero is an innovative library designed to simplify the creation of view controller transitions in iOS applications. It acts as a higher-level abstraction over UIKit's complex transition APIs, making it easier for developers to implement custom animations seamlessly.
Key Features
Hero's functionality is similar to Keynote's Magic Move. By evaluating the heroID
property on views within the source and destination controllers, Hero automatically animates the transition between matching views. This automation significantly reduces the need for manual setup and coding.
In addition to handling matched views, Hero can animatel unmatched views by using the heroModifiers
property. With this, developers can define custom animations to run concurrently with the Magic Move animations, which can be controlled interactively using user gestures.
At the view controller level, Hero supports several template transitions that can be specified using heroModalAnimationType
, heroNavigationAnimationType
, and heroTabBarAnimationType
. These templates can lay the foundation for custom transitions, and developers can further customize them using heroID
and heroModifiers
to craft unique effects.
Dynamic and Consistent Animations
By default, Hero incorporates dynamic durations inspired by the Material Design Motion Guide. This feature adjusts the duration of transitions based on the amount of distance and size change, ensuring that animations remain fluid and engaging without requiring extra configuration.
Hero is designed to integrate seamlessly with common UI structures like Auto Layout, programmatic layouts, UICollectionView, UITableView, UINavigationController, and UITabBarController without altering their states, except for temporarily hiding them during transitions.
Installation Options
Hero is highly accessible and easy to integrate into projects through several package managers:
- CocoaPods: Simply add
pod 'Hero'
to your Podfile and runpod install
. - Carthage: Add
github "HeroTransitions/Hero"
to your Cartfile, then executecarthage update
. - Accio: Include
package(url: "https://github.com/HeroTransitions/Hero.git", .upToNextMajor(from: "1.4.0"))
in yourPackage.swift
. - Swift Package Manager: Add Hero as a dependency in your
Package.swift
withpackage(url: "https://github.com/HeroTransitions/Hero.git", .upToNextMajor(from: "1.3.0"))
. - Manual Installation: Drag and drop the Sources folder into your project.
Usage Examples
Hero is straightforward to use, and its capabilities can be explored through different usage scenarios. For instance, view controllers can be configured with identifiers and modifiers to match views and execute planned transitions, both in code and through storyboard configurations.
Here are examples for two different usage scenarios:
- Basic View Transition: Assign
hero.id
to match views across view controllers for seamless transitions. - Complex Animations: Apply cascade and other effects on collectionView cells using
heroModifiers
, demonstrating more advanced customization potential.
Documentation and Support
For comprehensive guidance, Hero offers detailed usage documentation, FAQs, and even interactive transition tutorials. Developers can refer to the WIKI PAGES for step-by-step instructions or explore header-docs in Xcode for in-depth details.
Hero encourages contributions from the developer community. If you're interested in improving the library or contributing, refer to the Contribution Guide for more information.
By providing a powerful and declarative approach to view transitions, Hero transforms the way animations are built into iOS applications, making them smoother, more intuitive, and developer-friendly.