HeroTransitions / Hero

Elegant transition library for iOS & tvOS
https://HeroTransitions.github.io/Hero/
MIT License
22.02k stars 1.72k forks source link

Over fullscreen transitions persist snapshots #683

Open ktan17 opened 4 years ago

ktan17 commented 4 years ago

What did you do?

When using a full screen Hero transition which scales a UIImageView to the size of the full-screen (transitioning to another view controller), the snapshot used during the transition remains in the view hierarchy post-animation. This is caused by the following code in HeroTransition+Complete:

if finished && isPresenting && toOverFullScreen {
   // finished presenting a overFullScreen VC
  context.unhide(rootView: toView)
  context.removeSnapshots(rootView: toView)
  context.storeViewAlpha(rootView: fromView)
  fromViewController?.hero.storedSnapshot = container
  container.superview?.addSubview(fromView)
**fromView.addSubview(container)
} else if !finished && !isPresenting && fromOverFullScreen {
  // cancelled dismissing a overFullScreen VC
  context.unhide(rootView: fromView)
  context.removeSnapshots(rootView: fromView)
  context.storeViewAlpha(rootView: toView)
  toViewController?.hero.storedSnapshot = container
  container.superview?.addSubview(toView)
**toView.addSubview(container)
}

Normally, this is okay; however, if the background of the presented view controller (and its subviews) are made transparent, then you can see the snapshot behind it. I believe this is the same issue outlined in https://github.com/HeroTransitions/Hero/issues/518.

What did you expect to happen?

The snapshot should not be visible. I'm not sure for what purpose it needs to be there, but perhaps a property can added to hide it. When commenting out the asterisked lines above, the transition still works properly and the snapshot is hidden.

General Information

ThoseGuysInTown commented 3 years ago

Found a solution. Commented here: https://github.com/HeroTransitions/Hero/issues/289#issuecomment-705248194