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

Created on 2 Dec 2017  路  15Comments  路  Source: HeroTransitions/Hero

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.

Most helpful comment

Hero.shared.containerColor = .clear

All 15 comments

I found this problem too. I have made a screen recorder, notice that is the screen shot image change to back color. Like photo negatives. I test in iPhone7, iPhone6S, all iOS11, it's cool, but in iPhoneX and iOS 11.2锛宨t happens.

BTW, @lucasgv 's change alpha works.

yep same here, happening only on iPhone X

Where's the Hero.swift file? I think I see no file in my project called Hero.swift.

@CeceXX The Hero.swift is in your pods project, Open your project.xcworkspace go to Pods > Hero > Hero.swift.

If you don't use pods, probably will be in your Hero imported project

Regards!

In my case caused by ". useLayerRenderSnapshot" . It was painting transparent areas as black

In Hero.swift, setting afterScreenUpdates to false fixed the problem as well. Not sure if this will have unintended consequences for another transition.

fullScreenSnapshot = transitionContainer.window?.snapshotView(afterScreenUpdates: false) ?? fromView.snapshotView(afterScreenUpdates: false)

Interestingly enough, I fixed the issue by installing Hero manually instead of using Pods and adding the Source folder to my project.

Still viewcontroller has black background instead transparent :(

I'm not convinced setting snapshotView(afterScreenUpdates: false is a reasonable answer because you may need to set this value to true under certain circumstances e.g. if the view controller whose view you wish to snapshot hasn't updated yet...

still flashing with .zoom type

Hero.shared.containerColor = .clear

@asd4059 not fixed

@asd4059 worked for me, instead of using clear though you can use whatever color you want for the background color. For instance:
Hero.shared.containerColor = UIColor.white

Not sure if anyone is still observing this thread, but I was facing the issue while I had tabBarController?.navigationController?.navigationBar.isTranslucent = false, and once I deleted the line the black flicker went away for me.

So if you have it, remove self.tabBarController?.navigationController?.navigationBar.isTranslucent = false

for my case using .useNormalSnapshot fixes the issue

Was this page helpful?
0 / 5 - 0 ratings