قالب وردپرس درنا توس
Home / IOS Development / ios – How to change the color of display fade in CATransition

ios – How to change the color of display fade in CATransition



I implement a custom CATransition so that I can presentViewController from left or right instead of the bottom, but encounter an interesting problem with what the CAT Transition does.

Here is my code:

  let transition: CATransition = CATransition ()
transition.duration = 2

transition.timingFunction = CAMediaTimingFunction (name: kCAMediaTimingFunctionDefault)
transition.type = kCATransitionMoveIn
transition.subtype = kCATransitionFromLeft
self.view.window? .layer.addAnimation (transition, forKey: zero)

Everything works as expected with the view being presented, but what happens with the view being replaced is what is interesting. It slowly disappears to black, creating a nasty black flash before my new view is completely animated.

As shown in the picture below, the closer my new view will be fully animated, the darker the old view becomes. It reaches full black just before the display is completely reshaped.

 enter picture description here


Source link