Elegant transition library for iOS & tvOS

Overview

Hero is a library for building iOS view controller transitions. It provides a declarative layer on top of the UIKit's cumbersome transition APIs—making custom transitions an easy task for developers.

Carthage compatible Accio supported codecov Version License Xcode 9.0+ iOS 8.0+ Swift 4.0+ 中文 README Donate

      

Hero is similar to Keynote's Magic Move. It checks the heroID property on all source and destination views. Every matched view pair is then automatically transitioned from its old state to its new state.

Hero can also construct animations for unmatched views. It is easy to define these animations via the heroModifiers property. Hero will run these animations alongside the Magic Move animations. All of these animations can be interactively controlled by user gestures.

At view controller level, Hero provides several template transitions that you can set through heroModalAnimationType, heroNavigationAnimationType, and heroTabBarAnimationType. These can be used as the foundation of your custom transitions. Combine with heroID & heroModifiers to make your own unique transitions.

      

By default, Hero provides dynamic duration based on the Material Design Motion Guide. Duration is automatically determined by changes to distance and size—saving you the hassle, while providing consistent and delightful animations.

Hero doesn't make any assumptions about how the view is built or structured. It won't modify any of your views' states other than hiding them during the animation. This makes it work with Auto Layout, programmatic layout, UICollectionView (without modifying its layout object), UITableView, UINavigationController, UITabBarController, etc...

Usage Example 1

View Controller 1

redView.hero.id = "ironMan"
blackView.hero.id = "batMan"

View Controller 2

self.hero.isEnabled = true
redView.hero.id = "ironMan"
blackView.hero.id = "batMan"
whiteView.hero.modifiers = [.translate(y:100)]

Usage Example 2

View Controller 1

greyView.hero.id = "skyWalker"

View Controller 2

self.hero.isEnabled = true
greyView.hero.id = "skyWalker"

// collectionView is the parent view of all red cells
collectionView.hero.modifiers = [.cascade]
for cell in redCells {
    cell.hero.modifiers = [.fade, .scale(0.5)]
}

You can do these in the storyboard too!

Installation

CocoaPods

Add the following entry to your Podfile:

pod 'Hero'

Then run pod install.

Don't forget to import Hero in every file you'd like to use Hero.

Carthage

Add the following entry to your Cartfile:

github "HeroTransitions/Hero"

Then run carthage update.

If this is your first time using Carthage in the project, you'll need to go through some additional steps as explained over at Carthage.

Accio

Add the following to your Package.swift:

.package(url: "https://github.com/HeroTransitions/Hero.git", .upToNextMajor(from: "1.4.0")),

Next, add Hero to your App targets dependencies like so:

.target(
    name: "App",
    dependencies: [
        "Hero",
    ]
),

Then run accio update.

Swift Package Manager

To integrate using Apple's Swift package manager, add the following as a dependency to your Package.swift:

.package(url: "https://github.com/HeroTransitions/Hero.git", .upToNextMajor(from: "1.3.0"))

and then specify "Hero" as a dependency of the Target in which you wish to use Hero. Here's an example PackageDescription:

// swift-tools-version:4.0
import PackageDescription

let package = Package(
    name: "MyPackage",
    products: [
        .library(
            name: "MyPackage",
            targets: ["MyPackage"]),
    ],
    dependencies: [
        .package(url: "https://github.com/HeroTransitions/Hero.git", .upToNextMajor(from: "1.6.1"))
    ],
    targets: [
        .target(
            name: "MyPackage",1.6.1
            dependencies: ["Hero"])
    ]
)

Manually

  • Drag the Sources folder anywhere in your project.

Documentations

Checkout the WIKI PAGES (Usage Guide) for documentations.

For more up-to-date ones, please see the header-doc. (use alt+click in Xcode)

Interactive Transition Tutorials

Interactive transitions with Hero (Part 1)

FAQ

Not able to use Hero transition even when self.hero.isEnabled is set to true

Make sure that you have also enabled self.hero.isEnabled on the navigation controller if you are doing a push/pop inside the navigation controller.

Views being covered by another matched view during the transition

Matched views use global coordinate space while unmatched views use local coordinate space by default. Local coordinate spaced views might be covered by other global coordinate spaced views. To solve this, use the useGlobalCoordinateSpace modifier on the views being covered. Checkout Coordinate Space Wiki page for details.

Push animation is shown along side my custom animation

This is the default animation for navigation controller provided by Hero. To disable the push animation, set self.hero.navigationAnimationType to .fade or .none on the navigation controller.

How do I use a different default animation when dismissing

You can use the animation type .selectBy(presenting:dismissing) to specify a different default animation for dismiss.

For example:

    self.hero.modalAnimationType = .selectBy(presenting:.zoom, dismissing:.zoomOut)

Contribute

We welcome any contributions. Please read the Contribution Guide.

Comments
  • Redesign `heroModifiers` to not be a string API

    Redesign `heroModifiers` to not be a string API

    I think the API would be far clearer and easy to use if heroModifers wasn't a string. The benefits of a non "stringly-typed" API are pretty clear, but to outline a few:

    • Improved safety
    • Compiler checking
    • Easier discoverability and documentation

    I would love to take on this task, but I wanted to ask which of two directions I should go, and if you might merge a PR like this before I start working on it.

    Option 1

    Introduce a new Enum with associated values for each Modifier - something like

    enum Modifier {
        case scale(CGFloat)
        case fade
        case ...
    }
    

    Views would retain the heroModifiers property, but it would become an array of Modifier, used like this: foo.heroModifiers = [.fade, .scale(0.5)].

    This design is nice because an enum encapsulates the possible modifiers well, especially with associated values. One drawback is that it's unclear at usage that you can only use one of each Modifier. However, the current String API also has this problem.

    Option 2

    Introduce a new Modifiers struct with optional properties for each Modifier, something like:

    struct Modifiers {
        var scale: CGFloat?
        var fade = false
        var transform: (CGFloat, CGFloat)?
        ...
    }
    

    This design is nice because it ensures one of each Modifier is used at the most. Views would also have a heroModifiers property, but would be the type of the struct. This design might be used like this:

    foo.heroModifiers.scale = 0.5
    foo.heroModifiers.fade = true
    

    I'd love your opinion on this, or would love to know if you're already working on something similar. I'd love to help implement it!

    enhancement discussion WIP 
    opened by kylebshr 42
  • [Bug] Modal transitions stopped working after first hero transition

    [Bug] Modal transitions stopped working after first hero transition

    What did you do?

    I use the following to display a VC with a modal transition: self.present(vc, animated: true) {}

    What did you expect to happen?

    I expect the normal behavior of IOS 13: IMG_6509

    However, this only works before using a Hero transition at another place in the app the first time!

    What happened instead?

    As soon as I have used Hero Transition the first time elsewhere in the app, the same modal transition behaves like this:

    IMG_6510

    From this point, all modal transitions in the app behave like this.

    Any ideas? Thanks in advance!

    • Hero Version: 1.5.0

    • iOS Version(s): 13.2

    • Swift Version: 5.0

    • Devices/Simulators: Both

    confirmed bug reopen if needed 
    opened by StefanLdhl 24
  • Screen freezes (no crash just frozen)

    Screen freezes (no crash just frozen)

    I have implemented this logic on view controller A with presents view controller B. View controller be will sometimes just fail to dismiss and remain stuck on screen with no way out except by force killing the app. This does not cause any exception just a frozen app.

    View controller A presenting B:

    let vc = PrizeDetailsViewController() vc.hero.isEnabled = true vc.hero.modalAnimationType = .selectBy(presenting: .pageIn(direction: .left), dismissing: .pageOut(direction: .right))

    This is the dismiss logic for view controller B, it has a pan gesture recognizer and a back button. A and B are regular UIViewController (no UINavigationController).

    dismiss logic in B:

    func backButtonPressed(sender: UIButton) { hero.dismissViewController() }

    `func handlePan(gestureRecognizer:UIPanGestureRecognizer) { let translation = panGR.translation(in: nil) let progress = translation.x / 2 / view.bounds.width

        if translation.x < 0 {
            Hero.shared.cancel()
        }
        
        switch panGR.state {
        case .began:
            // begin the transition as normal
            //dismiss(animated: true, completion: nil)
            hero.dismissViewController()
        case .changed:
            Hero.shared.update(progress)
            
            // update views' position (limited to only vertical scroll)
            Hero.shared.apply(modifiers: [.position(CGPoint(x:translation.x/2.0 + view.center.x, y:view.center.y))], to: view)
            //            Hero.shared.apply(modifiers: [.position(CGPoint(x:nameLabel.center.x, y:translation.y + nameLabel.center.y))], to: nameLabel)
        //            Hero.shared.apply(modifiers: [.position(CGPoint(x:descriptionLabel.center.x, y:translation.y + descriptionLabel.center.y))], to: descriptionLabel)
        default:
            // end or cancel the transition based on the progress and user's touch velocity
            if progress + panGR.velocity(in: nil).x / view.bounds.width > 0.3 {
                Hero.shared.finish()
            } else {
                Hero.shared.cancel()
            }
        }
    }`
    

    This works 90% of the time but for some reason will just stop randomly. I am wondering if I am setting it up properly.

    Thanks

    reopen if needed 
    opened by jjjeeerrr111 24
  • image animation

    image animation

    @pborreli @e28eta @mRs- @sgl0v @CalebeNP I have an image animation where an image inside a cell goes to fill the entire view of the view controller. Do you mind helping me. Because it almost looks like the images overlaps the image of the detail page view controller and then disappears.

    opened by jackpaster 23
  • Swipe to back (Navigation)

    Swipe to back (Navigation)

    That question was already raised before. How can I enable swipe to back if hero was used within navigationController?.pushViewController? Hero disables swipes now, so application become very unintuitive without default swipe gestures in navigation controllers.

    reopen if needed 
    opened by Sorix 22
  • crash in Hero.shared.end(), when pan too quickly

    crash in Hero.shared.end(), when pan too quickly

    when I pan an imageView in my app too quickly, it causes app crash sometimes,

    context: HeroContext! is null

    fatal error: unexpectedly found nil while unwrapping an Optional value 2017-05-16 10:58:52.556929+0800 soocii[44033:7935298] fatal error: unexpectedly found nil while unwrapping an Optional value

    confirmed bug discussion investigating reopen if needed 
    opened by PatrickSCLin 21
  • Freezing screen after navigating back and forth between screens

    Freezing screen after navigating back and forth between screens

    I create transaction from tableView to ViewController with animation some images from cell to view. After fore of five transactions to and back, transaction freezing. It's look like viewcontroller dismissed but snapshot view still showing. I guess my view controller closed before animation is completed. Usually I close viewcontoller self.dismiss(animated: true, completion: nil)

    reopen if needed 
    opened by MZakopailov 16
  • Hero (1.3.0): .overCurrentContext doesn't show underlying view

    Hero (1.3.0): .overCurrentContext doesn't show underlying view

    Hey YiLun, Thumbs up for this amazing library!

    My issue is that I have a black background when transition finished. This is my code: (maybe I am doing something wrong?)

    let vc = MyViewController(...)
    vc.hero.isEnabled = true
    vc.hero.modalAnimationType = .selectBy(presenting: .pull(direction: .left), dismissing: .pull(direction: .right))
    vc.modalPresentationStyle = .overCurrentContext
    vc.view.backgroundColor = .clear
    present(vc2, animated: true, completion: nil)
    

    When I set animated property to false present(vc2, animated: false, completion: nil) the background is transperent, but then I do not see the transition.

    Thanks in advance Luda

    reopen if needed 
    opened by fuxlud 16
  • Swift 4 - iOS 11 - Cascade transitions doesn't work

    Swift 4 - iOS 11 - Cascade transitions doesn't work

    Hi,

    I'm using Hero in my application and it was working perfectly until iOS 11, I only have one issue though, I'm applying a cascade modifier on the tableView to display the each cells with a delay. I case see the cascade when I build the app on iOS 9 and 10 but not on iOS 11.

    Is that a known issue ? Or many something that i'm missing ?

    Thanks ! Morgan

    reopen if needed 
    opened by morgan-legal 16
  • iOS 13, Page Sheet modal controller incorrect display.

    iOS 13, Page Sheet modal controller incorrect display.

    What did you do?

    I add Hero library to my project, set isHeroEnabled on ViewControllers and set HeroID on views. Add new modal controller with Page sheet.

    What did you expect to happen?

    I expect to happen views modification and transform on transition. In iOS 11-12 - all OK. And I expect to happen in iOS 13, that I can see my modal view controller with default ios 13 dismiss swipe, top rounded and over previos view controller. Something like this: https://prnt.sc/patp70

    What happened instead?

    But in iOS 13, I happened this: https://prnt.sc/pato7j And swipe down for dismiss dont work. This problem fixed, if I change presentation style to Full screen. But I want Page sheet presentation style. How I can fix this?

    General Information

    • Hero Version: 1.4.0

    • iOS Version(s): iOS 13.0

    • Swift Version: 5.0

    • Devices/Simulators: Simulator iPhone 11

    reopen if needed 
    opened by StasanTelnov 15
  • Fast Black background color from fullScreenSnapshot in Iphone 7 plus real device

    Fast Black background color from fullScreenSnapshot in Iphone 7 plus real device

    Hello,

    I had this problem yesterday, in iPhone 7 plus in the specific moment, when I show again the controller by the menu, this won't happens, I tested in 6s, 5s, 5e, and everything works fine. I don't know if I am doing something wrong but I fix the problem setting the alpha of fullScreenSnapshot to 0.0 in Hero.swift file.

    Follow my implementation, I have two view controllers using the HeroModifiers with durationMatchLongest in the views, the two viewcontrollers is equal, the difference is that one of them have more content in one label.

    My code:

    ViewControllerOne:

    self.view.heroID = "viewHeroID"
    self.view.heroModifiers = [.useLayerRenderSnapshot]
    self.buttonPlay.heroID = "HeroIDButtonPlay"
    self.buttonPlay.heroModifiers = [.durationMatchLongest]
    

    the other components of my controller have the same code.

    ViewControllerTwo:

    self.view.heroID = "viewHeroID"
    self.view.heroModifiers = [.useLayerRenderSnapshot]
    self.buttonPlay.heroID = "HeroIDButtonPlay"
    self.buttonPlay.heroModifiers = [.durationMatchLongest]
    

    the other components of my controller have the same code.

    When I run the project, the first screen in the ViewControllerOne, when I do the push with the transition, show a black fullScreenSnapshot very fast and then go to ViewControllerTwo with the custom transition.

    When I open the side menu and close, if I do the same action the black fullScreenSnapshot not shown. But in others devices everything works fine. To fix this in the Hero.swift I change the alpha, this fixes the problem, but maybe I am doing something wrong if you have some help or suggestion, I would like to hear.

    The code in Hero.swift:

      fullScreenSnapshot = transitionContainer.window?.snapshotView(afterScreenUpdates: true) ?? fromView.snapshotView(afterScreenUpdates: true)
      (transitionContainer.window ?? transitionContainer)?.addSubview(fullScreenSnapshot)
      fullScreenSnapshot?.alpha = 0.0
    

    Thanks a lot! Hero is a great Library. Regards.

    reopen if needed 
    opened by lucasgv 15
  • Version 1.6.2 doesn't work with SPM

    Version 1.6.2 doesn't work with SPM

    What did you do?

    Updating from 1.6.1 to 1.6.2 using SPM doesn't work.

    What happened instead?

    /Users/redacted/Library/Developer/Xcode/DerivedData/app_redacted-asehfmfelcemwgdmpgoxlifocxtt/Build/Products/Debug-iphoneos/Hero error build: /Users/redacted/Library/Developer/Xcode/DerivedData/app_redacted-asehfmfelcemwgdmpgoxlifocxtt/Build/Products/Debug-iphoneos/Hero: No such file or directory

    spm 
    opened by guidev 15
  • Request: Make HeroTransition::complete(after: TimeInterval, finishing: Bool) public

    Request: Make HeroTransition::complete(after: TimeInterval, finishing: Bool) public

    This isn't a bug, but a feature request.

    Would it be possible to make the complete(after: TimeInterval, finishing: Bool) public instead of just complete(finishing: Bool)

    The main use case I have is when using interactive transitions. If you have a transition thats interactive, and say you finish your gesture when the progress is up to 0.8 or at least there abouts, due to being so 'close' to the end, the animation sometimes feels like it 'snaps' to the finish.

    Ideally, I'd like to dynamically alter the duration a bit and allow the animation to take longer to finish that final bit of progress than it would normally do when not interacting.

    I tried applying a duration modifier when interacting, but I think totalDuration is only calculated at the start - so maybe the alternative to be able to recalc totalDuration on the fly?

    opened by IainS1986 0
  • Animation not working for UICollectionViewDiffableDataSource

    Animation not working for UICollectionViewDiffableDataSource

    What did you do?

    I am trying to use Hero to animate transitions into a screen that is rendered with UICollectionView with UICollectionViewDiffableDataSource, by calling apply snapshot (NSDiffableDataSourceSnapshot)

    What did you expect to happen?

    To see the animation between the views that have matching hero ids

    What happened instead?

    The screen appears with the hero fade only On dismissing, the hero animations works perfectly (which removes the option that ids weren't defined properly, or any other setup issue)

    From my investigation, if I add a delay of 2 seconds before presenting the screen, the animation works. I also checked and saw that the the cells still didn't render when Hero tried to animate

    Also, in another screen, that works with the same lifecycle exactly but without the diffable datasource, the hero animation works! I also tried triggering apply snapshot without animations, or with the iOS 15 API (applySnapshotWithReloadData)

    Is there a way to get this to work?

    General Information

    • Hero Version: latest

    • iOS Version(s): 15.6.1

    • Swift Version: 5

    • Devices/Simulators: iPhone 13 (real device)

    opened by EyalHouzz 0
  • Crash on Hero.HeroTransition.start() -> () HeroTransition+Start.swift, line 121

    Crash on Hero.HeroTransition.start() -> () HeroTransition+Start.swift, line 121

    Spy
    0x100d10000 + 150232
    Spy
    0x100d10000 + 150264
    UIKitCore
    -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
    QuartzCore
    CA::Layer::layout_if_needed(CA::Transaction*)
    UIKitCore
    -[UIView(Hierarchy) layoutBelowIfNeeded]
    Hero
    Hero.HeroTransition.start() -> () HeroTransition+Start.swift:121
    Hero
    Hero.HeroTransition.animateTransition(using: __C.UIViewControllerContextTransitioning) -> () HeroTransition+UIViewControllerTransitioningDelegate.swift:64
    Hero
    @objc Hero.HeroTransition.animateTransition(using: __C.UIViewControllerContextTransitioning) -> () <compiler-generated>:0
    UIKitCore
    ___UIViewControllerTransitioningRunCustomTransition_block_invoke_2
    UIKitCore
    +[UIKeyboardSceneDelegate _pinInputViewsForKeyboardSceneDelegate:onBehalfOfResponder:duringBlock:]
    UIKitCore
    ___UIViewControllerTransitioningRunCustomTransition_block_invoke.663
    UIKitCore
    +[UIView(Animation) _setAlongsideAnimations:toRunByEndOfBlock:]
    UIKitCore
    _UIViewControllerTransitioningRunCustomTransition
    UIKitCore
    -[UINavigationController _startCustomTransition:]
    UIKitCore
    -[UINavigationController _startDeferredTransitionIfNeeded:]
    UIKitCore
    -[UINavigationController __viewWillLayoutSubviews]
    UIKitCore
    -[UILayoutContainerView layoutSubviews]
    UIKitCore
    -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
    QuartzCore
    CA::Layer::layout_if_needed(CA::Transaction*)
    QuartzCore
    CA::Layer::layout_and_display_if_needed(CA::Transaction*)
    QuartzCore
    CA::Context::commit_transaction(CA::Transaction*, double, double*)
    QuartzCore
    CA::Transaction::commit()
    QuartzCore
    CA::Transaction::flush_as_runloop_observer(bool)
    CoreFoundation
    __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
    CoreFoundation
    __CFRunLoopDoObservers
    CoreFoundation
    __CFRunLoopRun
    CoreFoundation
    CFRunLoopRunSpecific
    GraphicsServices
    GSEventRunModal
    UIKitCore
    -[UIApplication _run]
    UIKitCore
    UIApplicationMain
    libswiftUIKit.dylib
    UIKit.UIApplicationMain(Swift.Int32, Swift.UnsafeMutablePointer<Swift.UnsafeMutablePointer<Swift.Int8>>?, Swift.String?, Swift.String?) -> Swift.Int32
    Spy
    0x100d10000 + 27432
    0x0 + 0
    Collapse
    
    
    confirmed bug 
    opened by sadeghgoo 4
  • animations won't work after switching and switching back on tabBarController

    animations won't work after switching and switching back on tabBarController

    What did you do?

    I have a main navigationController in my app that navigates between login page and the main tabBar. the tabBar it self has two child controllers which are both navigationControllers

    there is this weird thing with "isHeroEnabled" in the navigationController where if i set it to true in viewDidLoad, hero animations won't work! but if i don't touch it it'll work fine! but that's not the problem!

    when the tabbar loads the first page works perfectly fine with all the animations and everything! the problem begins when i switch to next tab and then go back to my first page and find it with no animation! it just awkwardly slides to right to show the next viewController as if hero is not enabled (tho i checked and indeed it was enabled for both vc's and the navigation controller)

    What did you expect to happen?

    for animations to work!

    What happened instead?

    they did not!

    General Information

    • Hero Version: 1.6.1

    • iOS Version(s): 13

    • Swift Version: 5

    • Devices/Simulators: iPhone 13 pro max

    • Reproducible in Examples? (Yes/No): yes

    bug? 
    opened by SaeeSaadat 1
Releases(1.6.2)
  • 1.6.2(Sep 1, 2022)

    Source code(tar.gz)
    Source code(zip)
  • 1.6.1(Mar 7, 2021)

  • 1.6.0(Feb 15, 2021)

    1.6.0

    Added

    • #695 - Swift 5 support
    • #628 - Swift Package Manager Support
    • #623 - Swift UI support and example
    • #681 - Application extension target support
    • #595 - Add Accio supported badge
    • #619 - XCode 11/12 support in example
    • CI/CD improvements

    Changed

    • #648 - Updated iOS version support
    • #576 - Usage guide updates
    Source code(tar.gz)
    Source code(zip)
    Hero.framework.zip(1.86 MB)
  • 1.5.0(Feb 15, 2021)

    Maintainance Pre-Swift 5 release.

    New maintainers

    CHANGELOG

    1.5.0

    Added

    • Use custom snapshot for views that implement HeroCustomSnapshotView. #541 by @ManueGE

    Changed

    • Added support for right to left languages. #520 by @ManueGE

    • The hidden state of subviews are now taken into account in optimized snapshot type for UIImageView. #521 by @ManueGE

    Commits

    • Fix iOS demo app failing and style on iOS 13
    • Fix lint warnings and build errors in demo app
    • Add extra metadata to podspec
    • Deprecated messages to renamed
    • Add Joe Mattiello into Podspec authors for publishing
    • Fix pod lib lint failures
    • Update Podspec imports to match source imports
    • Use more minimal import
    • Remove Swift files from framework bundle products
    • Remove access modifier warnings (#616)
    • GitIgnore xcode log files
    • Docs - Run jazzy against new spec
    • Docs - Update jazzy config
    • Bump version to 1.5.0
    • Set theme jekyll-theme-midnight
    • Use custom snapshot for views that implements HeroCustomSnapshotView (#541)
    • Keep using default navigation animation direction with RTL languages (#520)
    • Hidden subviews not taken in account in optimized snapshot type (#521)
    • Update Collection 2.0 (#553)
    Source code(tar.gz)
    Source code(zip)
    Hero.framework.zip(13.69 MB)
  • 1.4.0(Oct 14, 2018)

    This release adds support for Swift 4.2 and also maintains backward compatibility for previous Swift versions. Thank you to @rennarda for contributing to this release 🥇

    Added

    Source code(tar.gz)
    Source code(zip)
  • 1.3.1(Sep 11, 2018)

    This release fixes a retain cycle caused by strong references to delegates.

    Thanks to @mkieselmann for contributing to this release 👊🥇💯

    Fixed

    • Fixed the retain cycle caused by strong references to previousNavigationDelegate and previousTabBarDelegate. #516 by @mkieselmann
    Source code(tar.gz)
    Source code(zip)
  • 1.3.0(Jul 30, 2018)

    This version fixes a few bugs related to animations and improves handling of UINavigationController delegate events and the ability to provide completion blocks for basic transition methods.

    Thanks to @lkzhao, @2blane, @kartikthapar, and @bradphilips for contributing to this release 💪💯🥇

    Added

    • Adds an optional completion block parameter to the dismissViewController and replaceViewController methods. #456 by @kartikthapar

    Changed

    • Allows previous UINavigationController delegate to handle delegate events. #430 by @bradphilips

    Fixed

    • Fixed shadows being cutoff by snapshots. #440 by @2blane
    • Fixed animation flickering on CALayer animation. f4dab9 by @lkzhao
    Source code(tar.gz)
    Source code(zip)
  • 1.2.0(Apr 12, 2018)

    • add HeroTransitionDelegate for observing transition state and progress

    • add ability to change target state during interactive transition. https://github.com/lkzhao/Hero/issues/322

      Just call the following method before calling finish(animate:) and provide the target state similar to apply(modifiers:, to:)

      Hero.shared.changeTarget(modifiers:, to:)
      

      for example:

      someView.hero.modifiers = [.translate(x: 100)]
      
      // when you want to finish interactive transition
      Hero.shared.changeTarget(modifiers:[.translate(x: -100)], to: someView)
      Hero.shared.finish()
      // this will animate someView to the state of `.translate(x: -100)` instead of `.translate(x: 100)`
      
    • a number of bug fixes and improvements:

      • fix 2x mode on ipad
      • Add type hinting to CascadeDirection comperator (#403) @BennX
      • Update for Xcode 9.3 and Swift 4.1 (#439) @joaomvfsantos
      • Add UIView+Hero.swift and UIViewController+Hero.swift to public heade… (#425) @DanielAsher
      • copy image view resizing filter to snapshot (#428) @sroik
      • TabBarController.selectedViewController issue (#407) @dDomovoj
      • Fix typo on 'Advanture' (#398) @fabiothiroki
      • Update README.zh-cn.md (#429) @Fidetro
    Source code(tar.gz)
    Source code(zip)
  • 1.1.0(Feb 7, 2018)

    • Added Constrained extension to make API more elegant. (#367) Big thanks to @dDomovoj for making this happen!
    view.heroID -> view.hero.id
    view.heroModifiers -> view.hero.modifiers
    // etc..
    
    • Make tvOS Shared to be detected by carthage (#370) Credit to: @fruitcoder
    • Prevents animation from restarting when new UITabBarController tab is pressed rapidly multiple times (#373) Credit to: @armandsLa
    • Fix debug plugin to respect iPhone X safe insets (#375) Credit to: @nick-potts
    • Fix a force unwraps crashes. (#335) @imougy
    • Fix tabbar issues with hideButtonBarOnPush
    • Internal cleanup with CG extensions (#369) @adamnemecek
    • Fix internal influencing other animations libraries.
    Source code(tar.gz)
    Source code(zip)
  • 1.0.1(Nov 22, 2017)

    • fix an issue where interactive transition happens abruptly (#299) @capt-hook
    • fix a force unwrap crash (#333) @imougy
    • fix a division by zero crash when size is zero (#313) @caihua
    • Use context's final frame for destination (#327) @zacwest
    • Changes observeForProgressUpdate protection level to public, instead of internal (#329) @mad102190
    • ability to override cornerRadius for matched view
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0(Oct 25, 2017)

    This release fix some compatibility issue with swift 4, Xcode 9, and iOS 11.

    Also looking for a maintainer!

    Hero helped me learned a lot about iOS over the last year. Fighting the iOS animation system and dealing with UI bugs has been quite a journey. But I am sorry to say that I do not have to time to maintain this project anymore. The scope of this project has become unmanageable for me to handle. I am looking for a project maintainer to this project and I'm open to transfer this to a public organization instead of under my personal account.

    I will still be using Hero in productions, and contribute to critical bug fixes and new iOS release.

    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-alpha.4(Jul 21, 2017)

  • 1.0.0-alpha.3(Jul 18, 2017)

    • fix an issue where views that are contained in a transformed view are not animated properly https://github.com/lkzhao/Hero/issues/237
    • less force-unwraps.
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-alpha.2(Jul 14, 2017)

    This is the second alpha version for 1.0.0 release. Mostly bug fixes.

    • fix an issue where the duration is incorrect when resuming an animation with delay
    • fix a performance issue with interactive transition
    • remove most of the force unwrapped optional
    • fix a crash where finish/cancel is called before the animation has started.
    • make internal CAMediaTimingFunctions public
    • default container color is now black. to customize, construct your own HeroTransition object.

    Example project

    • animate tabbar so that it doesnt cover the content
    • add a playground in the example project for quick tests
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-alpha.1(Jun 30, 2017)

    Sorry guys for the inactivity with this project. I have been having some other commitments. From now on, I will start maintaining and updating it more often.

    So to prepare for stable release 1.0, there will be a few alpha versions. I will start to clean up issues and start monitor new ones. Feel free to submit anything you have encountered while using the new versions.

    New Features

    • .useNoSnapshot will now try to insert the view back to the view hierarchy once the transition completes. So you don't need to manually insert it back.

      • Note: for views that have collection view or table view as the superview, Hero might not be able to insert it into the correct subview index since the collection view and table view might have altered their subviews during the transition.
    • .useNoSnapshot will now animate subview layout changes. Very convenient when you want your custom layout be animated during the transition.

    • Added .whenXXX modifiers to make hero more declaritive.

      • instead of conforming to HeroViewControllerDelegate, you can now use .whenPresenting, .whenDismissing, .whenApearing, .whenDisapearing, .whenMatched, or your own conditions with .when
    • Added isHeroEnabledForSubviews property on UIView. Setting this to true will let Hero skip over the subview tree. This saves a lot of computation time when the subview tree is complex.

    • Better support iOS custom keyboard

    • Better support UIVisualEffectView

    • You can now create your own instance of HeroTransition instead of using isHeroEnabled & Hero.shared.

      • just create an instance of HeroTransition and assign it to the transitionDelegate property of your view controller.
    • Added viewOrderingStrategy property to HeroTransition which allow you to customize which view controller should be inserted first during the transition.

    • Added isUserInteractionEnabled property to HeroTransition which allow you to enable user interaction during the transition.

      • Note: by default, Hero will create snapshot of your views and use them for animation. They don't have the same event handler as your own views. So to enable user interaction, you have to apply .useNoSnapshot modifier to the views that you want to enabled user interaction. Also keep in mind that Hero can be in any state when you are handling user interaction. If you want to trigger a new transition, besure to call cancel(animated: false) or finish(animated: false) before starting the new transition.
    • The following methods on Hero is removed in favor of creating your custom HeroTransition object

      • func disableDefaultAnimationForNextTransition()
      • func setDefaultAnimationForNextTransition(_ animation: HeroDefaultAnimationType)
      • func setContainerColorForNextTransition(_ color: UIColor?)

    Bug fixes:

    • fix the ghosting effect where the source view and target view animates at different rate
    • fix tab bar crashes and inconsistency when tapping too fast.

    Future Roadmap:

    1. Custom snapshot view
    2. Masking support
    Source code(tar.gz)
    Source code(zip)
  • 0.3.6(Mar 16, 2017)

  • 0.3.5(Mar 15, 2017)

  • 0.3.4(Mar 11, 2017)

    • added three new string properties to set defaultAnimation

      • heroModalAnimationTypeString
      • heroNavigationAnimationTypeString
      • heroTabBarAnimationTypeString
    • new string parser that will give some error feedback

    • fix speed different bug for interaction transition #132

    • other small bug fixes.

    Source code(tar.gz)
    Source code(zip)
  • 0.3.3(Feb 25, 2017)

  • 0.3.2(Feb 16, 2017)

    • new properties for specifying default animations
    extension UIViewController {
      /// default hero animation type for presenting & dismissing modally
      public var heroModalAnimationType: HeroDefaultAnimationType
    }
    extension UINavigationController {
      /// default hero animation type for push and pop within the navigation controller
      public var heroNavigationAnimationType: HeroDefaultAnimationType
    }
    extension UITabBarController {
      /// default hero animation type for switching tabs within the tab bar controller
      public var heroTabBarAnimationType: HeroDefaultAnimationType
    }
    
    • bug fixes https://github.com/lkzhao/Hero/issues/90 https://github.com/lkzhao/Hero/issues/85
    • basic support for animating UIVisualEffectView's effect property in iOS 10
    Source code(tar.gz)
    Source code(zip)
  • 0.3.1(Feb 12, 2017)

  • 0.3.0(Feb 11, 2017)

    • support .overFullScreen modalPresentationStyle
    • Implement many new default transitions. (fade was the only default transition before this update)
      • .push(direction: Direction)
      • .pull(direction: Direction)
      • .cover(direction: Direction)
      • .uncover(direction: Direction)
      • .slide(direction: Direction)
      • .zoomSlide(direction: Direction)
      • .pageIn(direction: Direction)
      • .pageOut(direction: Direction)
    • a few new modifiers:
      • beginWith(modifiers:[HeroModifier])
      • durationMatchLongest
      • overlay(color:UIColor, opacity:CGFloat)
      • masksToBounds(_ masksToBounds: Bool)
    Source code(tar.gz)
    Source code(zip)
  • 0.1.9(Feb 7, 2017)

    • prepare for tvOS release
    • Add new zPosition modifier that animates zPosition from/to a given value. The old zPosition & zPositionIfMatched modifiers are removed. If you still want to modify the draw order, set the zPosition property on the view's layer before transition. Check the Apple HomePage Example for how to do this.
    • Add shadow and border animation modifiers:
      • shadowPath
      • shadowRadius
      • shadowOpacity
      • shadowColor
      • shadowOffset
      • borderWidth
      • borderColor
    Source code(tar.gz)
    Source code(zip)
  • 0.1.8(Feb 6, 2017)

    • fix a bug where interactive transition won't start when calling update(progress:) with progress = 0
    • Hero can now determine the draw order match more accurately! This eliminate the need for zPosition modifier to be used in most cases.
    Source code(tar.gz)
    Source code(zip)
  • 0.1.7(Feb 5, 2017)

  • 0.1.6(Feb 5, 2017)

  • 0.1.5(Feb 5, 2017)

    0.1.5

    • fix a bug where toViewController's delegate callbacks are not being called

    • fix a bug where fromViewController's delegate callbacks receive incorrect parameters.

    • Add useScaleBasedSizeChange modifier.

      Force Hero use scale based size animation. This will convert all .size modifier into .scale modifier. This is to help Hero animate layers that doesn't support bounds animation. Also gives better performance when animating.

    Source code(tar.gz)
    Source code(zip)
  • 0.1.4(Feb 5, 2017)

    0.1.4

    • fix a bug where changing orientation doesn't affect previous VC. https://github.com/lkzhao/Hero/issues/60
    • fix a bug where the presented view controller has incorrect frame. https://github.com/lkzhao/Hero/issues/63, https://github.com/lkzhao/Hero/issues/56
    • New snapshot type modifiers:
      • useOptimizedSnapshot

        With this modifier, Hero will create snapshot optimized for different view type when animating. For custom views or views with masking, useOptimizedSnapshot might create snapshots that appear differently than the actual view. In that case, use .useNormalSnapshot or .useSlowRenderSnapshot to disable the optimization.

      • useNormalSnapshot

        Create snapshot using snapshotView(afterScreenUpdates:).

      • useLayerRenderSnapshot

        Create snapshot using layer.render(in: currentContext). This is slower than .useNormalSnapshot but gives more accurate snapshot for some views (eg. UIStackView).

      • useNoSnapshot

        Force Hero to not create any snapshot when animating this view. Hence Hero will animate on the view directly. This will mess up the view hierarchy. Therefore, view controllers have to rebuild its view structure after the transition finishes.

    • New navigation extension on UIViewController (mainly to support unwinding):
      • func hero_dismissViewController()

        Dismiss the current view controller with animation. Will perform a navigationController.popViewController if the current view controller is contained inside a navigationController.

      • func hero_replaceViewController(with:UIViewController)

        Replace the current view controller with another VC on the navigation/modal stack.

      • func hero_unwindToRootViewController()

        Unwind to the root view controller using Hero.

      • func hero_unwindToViewController(_ toViewController:)

        Unwind to a specific view controller using Hero.

      • func hero_unwindToViewController(withSelector: Selector)

        Unwind to a view controller that responds to the given selector using Hero.

      • func hero_unwindToViewController(withClass: AnyClass)

        Unwind to a view controller with given class using Hero.

      • func hero_unwindToViewController(withMatchBlock: (UIViewController) -> Bool)

        Unwind to a view controller that the match block returns true on.

    Source code(tar.gz)
    Source code(zip)
  • 0.1.3(Feb 1, 2017)

    • Support local coordinate space.

      | Global coordinate space | Local (parent's) coordinate space | | --- | --- | | Animating views are not affected by parent views' attributes | Animating views are affected by parent views' attributes | | When parent view moves, subviews that have its own modifiers do not move with the parent view. I.e. they are being taken out of the view hierarchy. | When parent view moves, subviews that have its own modifiers move along with the parent view. I.e. similar to how a view behave when its parent view moves. | | Used for matched views & views with source modifier. Global is the default prior to 0.1.3 | Local is the default coordinate space after 0.1.3 |

    • New useGlobalCoordinateSpace modifier. Force the view to use global coordinate space. I.e. won't move with its parent view.

    Source code(tar.gz)
    Source code(zip)
Owner
Hero Transitions
Makers of the Hero Animations framework for iOS
Hero Transitions
Simple and elegant Dropdown Transition

Simple and elegant dropdown transition for iOS Why? I needed to perform the dropdown transition in the app I was building and I've found many great li

Aidar Nugmanoff 63 Sep 22, 2022
Custom interactive transition like Apple Music iOS App (iOS 9). written in Swift.

MusicPlayerTransition Custom interactive transition like Apple Music iOS App. written in Swift. Demo See demo on Appetize.io Using Transition Animator

Airin 642 Nov 17, 2022
SPLarkController - Custom transition between controllers. Settings controller for your iOS app.

SPLarkController About Transition between controllers to top. You can change animatable height after presentation controller. For presentation and dis

Ivan Vorobei 965 Dec 17, 2022
A custom modal transition that presents and dismiss a controller with an expanding bubble effect.

A custom modal transition that presents and dismiss a controller inside an expanding and shrinking bubble. Screenshot Usage Install through CocoaPods:

Andrea Mazzini 3.3k Dec 28, 2022
This is a Swift based demo project to show how to make the transition Pinterest liked.

PinterestSwift Compatible with Xcode 11 / Swift 5.0 This is a Swift based demo project to show how to make the transition Pinterest 2.0+ liked. Refer

Nicholas Tau 1.9k Dec 20, 2022
This component implements transition animation to crumble view-controller into tiny pieces.

StarWars Animation This component implements transition animation to crumble view-controller into tiny pieces. Check this project on dribbble. Also, r

Yalantis 3.7k Dec 29, 2022
Library for smooth animation of images during transitions.

ImageTransition ImageTransition is a library for smooth animation of images during transitions. Something looks like below: e.g. UIImageView e.g. UIIm

shtnkgm 207 Dec 3, 2022
🌊 - Jelly is a library for animated, non-interactive & interactive viewcontroller transitions and presentations with the focus on a simple and yet flexible API.

Jelly is a library for animated, non-interactive & interactive viewcontroller transitions and presentations with the focus on a simple and yet flexibl

Sebastian Boldt 2.4k Dec 25, 2022
SamuraiTransition is an open source Swift based library providing a collection of ViewController transitions featuring a number of neat “cutting” animations.

SamuraiTransiton is a ViewController transition framework in Swift. It is an animation as if Samurai cut out the screen with a sword. transition types

hachinobu 273 Dec 29, 2022
Awesome iOS 11 appstore cards in swift 5.

Cards brings to Xcode the card views seen in the new iOS XI Appstore. Getting Started Storyboard Go to main.storyboard and add a blank UIView Open the

Paolo Cuscela 4.1k Dec 14, 2022
Custom-Transition - A repo about custom transition between two view controllers

Custom-Transition in SWIFT This is a repo about custom transition between two vi

Prakash Chandra Awal 0 Jan 6, 2022
Appstore card animation transition. UICollectionView and UITableView card expand animated transition

Appstore card animation transition. UICollectionView and UITableView card expand animated transition. This library tries to add the appstore transition to your own app. The goal is to be as simple as possible to integrate in an app while keeping the flexibility and customization alive.

appssemble 544 Dec 28, 2022
Simple and elegant Dropdown Transition

Simple and elegant dropdown transition for iOS Why? I needed to perform the dropdown transition in the app I was building and I've found many great li

Aidar Nugmanoff 63 Sep 22, 2022
An elegant and flexible tweening library for iOS and tvOS.

PMTween is an elegant and flexible tweening library for Objective-C, currently supporting the iOS and tvOS platforms. It offers sensible default funct

Brett Walker 349 Nov 25, 2022
A library to recreate the iOS Apple Music now playing transition

DeckTransition DeckTransition is an attempt to recreate the card-like transition found in the iOS 10 Apple Music and iMessage apps. Hereʼs a GIF showi

Harshil Shah 2.2k Dec 15, 2022
A drop-in universal library helps you to manage the navigation bar styles and makes transition animations smooth between different navigation bar styles

A drop-in universal library helps you to manage the navigation bar styles and makes transition animations smooth between different navigation bar styles while pushing or popping a view controller for all orientations. And you don't need to write any line of code for it, it all happens automatically.

Zhouqi Mo 3.3k Dec 21, 2022
A drop-in universal library helps you to manage the navigation bar styles and makes transition animations smooth between different navigation bar styles

A drop-in universal library helps you to manage the navigation bar styles and makes transition animations smooth between different navigation bar styles while pushing or popping a view controller for all orientations. And you don't need to write any line of code for it, it all happens automatically.

Zhouqi Mo 3.3k Dec 21, 2022
Custom interactive transition like Apple Music iOS App (iOS 9). written in Swift.

MusicPlayerTransition Custom interactive transition like Apple Music iOS App. written in Swift. Demo See demo on Appetize.io Using Transition Animator

Airin 642 Nov 17, 2022
Ios-card-transition - iOS CocoaPod to create beautiful card transitions

CSCardTransition CSCardTransition is a small library allowing you to create wond

Creastel 12 Oct 31, 2022
SPLarkController - Custom transition between controllers. Settings controller for your iOS app.

SPLarkController About Transition between controllers to top. You can change animatable height after presentation controller. For presentation and dis

Ivan Vorobei 965 Dec 17, 2022