# Screen blinks black in LogoReveal

**URL:** <https://forums.kodeco.com/t/screen-blinks-black-in-logoreveal/18251>\
**Category:** iOS Animations by Tutorials\
**Created:** [August 8, 2016, 1:41pm UTC](https://forums.kodeco.com/t/screen-blinks-black-in-logoreveal/18251 "2016-08-08T13:41:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon73867311](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@anon73867311](https://forums.kodeco.com/u/anon73867311)\
**Post date:** [August 8, 2016, 1:41pm UTC](https://forums.kodeco.com/t/screen-blinks-black-in-logoreveal/18251/1 "2016-08-08T13:41:37Z")

</div>

Hi there,  
the application LogoReveal from chapter 23 seems to have an issue. When starting the interactive transition by sliding and stopping before hitting the 50 percent mark, the transition gets cancelled as expected. But the screen turns black for the blink of an eye.

This happens for me on the simulator as well as on the phone.

Is there a way to get around that?

Thanks.

Best,  
Sven

---

<div class="post-metadata">

**Author:** ![hodgins](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/hodgins/32/81494_2.png) [@hodgins](https://forums.kodeco.com/u/hodgins)\
**Post date:** [November 24, 2016, 5:11am UTC](https://forums.kodeco.com/t/screen-blinks-black-in-logoreveal/18251/2 "2016-11-24T05:11:17Z")

</div>

Hi Sven,

I have the same problem. Did you ever find a solution? As a quick fix I did this in the RevealAnimator class:

```
    switch recognizer.state {
    case .changed:
        update(progress)
    case .cancelled, .ended:
        interactive = false
        let transitionLayer = storedContext!.containerView.layer
        transitionLayer.beginTime = CACurrentMediaTime()
        if progress < 0.5 {
            cancel()
            if progress > 0.05 {
                transitionLayer.speed = -0.9
            } else {
                transitionLayer.speed = -0.5
            }
        } else {
            transitionLayer.speed = 1.0
            finish()
        }
    default:
        break
    }

```

Just experimenting with the transitionLayer speed seemed to stop that black screen. I’m not sure why. But I feel like there’s a better way than this. I’m just not sure how.

Thanks,  
Eric

---

<div class="post-metadata">

**Author:** ![jonjones13](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jonjones13/32/71885_2.png) [@jonjones13](https://forums.kodeco.com/u/jonjones13)\
**Post date:** [June 19, 2017, 7:11pm UTC](https://forums.kodeco.com/t/screen-blinks-black-in-logoreveal/18251/3 "2017-06-19T19:11:35Z")

</div>

I’m also having this issue with the project. I seem to be able to mitigate the effect in the same way that Eric did, by adjusting the speed of the transition layer and the completionSpeed of the RevealAnimator object. This doesn’t completely fix the issue though, and I’d be interested if anyone else has come up with a more complete solution. It seems like it might be a runloop issue, but I haven’t been able to pin it down.

Thanks,  
Jon

---

<div class="post-metadata">

**Author:** ![jonjones13](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jonjones13/32/71885_2.png) [@jonjones13](https://forums.kodeco.com/u/jonjones13)\
**Post date:** [July 12, 2017, 4:18pm UTC](https://forums.kodeco.com/t/screen-blinks-black-in-logoreveal/18251/4 "2017-07-12T16:18:35Z")

</div>

Hi all -  
I’m not sure if this issue is still important to anyone, but I believe that I’ve found the reason that it’s has this blink. I noticed that by changing the layer speed, I could sometimes get the blink to diminish in frequency on the simulator - however, when I tested on a physical device, I noticed that blink would happen much more consistently, which was frustrating. It also feels fairly ‘hacky’ to specify arbitrary animation layer speeds to resolve an issue that seems more fundamental to the process.

After a lot of experimentation and testing, I reached a couple of conclusions. It seems that we get that blink when relying on the `animationDidStop` CALayerAnimation delegate method to tell the `transitionContext` to finish the animation. We are forced to use this delegate method since layer animations have no built in completion handlers, but this delegate method doesn’t get called until just _after_ the animation finished; this results in a perceptible gap between the completion of the animation and the completion message being sent to the transition context. I actually reproduced this behavior in a small sample app just to test this hypothesis, and I again had the blinking screen when relying on layer animations to carry out the view controller transition.

In terms of solutions that don’t involve arbitrary layer speeds, I found a couple. The first feels equally ‘hacky’ - calling `performSelector(afterDelay...` with a delay of the `duration` property. This circumvents the control the user has over the animation, so this probably wouldn’t work for interactive view controller transitions.

The other solution that I found was to rely on layer animations for most of the transition, but instead of animating the opacity using a layer animation, I used `animate(withDuration...` to animate the alpha of the view as needed, and then I used the completion handler of this view animation to send the completion message to the `transitionContext`. It seems that the transitionContext handles the message from a completion handler as we would normally expect, and the blinking behavior was eliminated.

It seems that, as a general rule, relying on the `animationDidStop` delegate method to complete the `transitionContext` transition will result in somewhat undefined behavior (please do correct me if I’m wrong here 🙂 )

I haven’t tested this with the `UIPercentDrivenTransitionAnimation`, but I believe the principle still holds, as I reproduced the blinking behavior using a non-interruptible layer driven transition animation in a separate application.

Anyways - just thought I’d share my findings with anyone else having a similar issue. It was pretty frustrating to deal with, and there wasn’t terribly much assistance online that I could find.

Thanks!  
Jon
