Reputation: 526
What I'm trying to do is push in from the left side with a custom animation using CATransitions. In my normal code I want to use duration of 0.3
, but in the example below I'm using 6.0
just so I can see the actual problem during the transition.
And it is really obvious that there is a fade going on when transitioning to the new view. The new view coming in fades from it's background color to the actual view, whereas the view that is sliding off screen fades from the actual view to it's background color. It's making for some odd looks when doing the push animation to transition.
Below is the code that I'm using for the transition. settingsController
is the controller I'm trying to animate to.
let transition = CATransition()
transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
transition.duration = 6.0
transition.type = kCATransitionPush
transition.subtype = kCATransitionFromLeft
self.navigationController?.view.layer.addAnimation(transition, forKey: nil)
UIView.transitionFromView(self.view, toView: settingsViewController.view, duration: 0, options: UIViewAnimationOptions.TransitionNone, completion: nil)
self.navigationController?.pushViewController(settingsViewController, animated: false)
And as mentioned, the actual sliding animation works as I want it to, however there is this fade that happens that just makes it not look right . I've been searching google and stackoverflow and have not seen a solution posted, so I'm wondering if anyone has any idea how to get rid of this fade, or even if there is a work around that "simulates" this behavior so the user experience looks as I want it to.
I've tried making the background colors of both views the same and it still doesn't look right.
Upvotes: 3
Views: 1719
Reputation: 535315
The usual way to use a sliding CATransition is to give the transitioning view/layer a superview that clips to bounds (or a superlayer that masks to bounds). That way, the sliding view/layer is not visible outside the superview's bounds, and we never see the fade.
Upvotes: 3