I have been trying to make my custom transition while presenting another view controller and I succeeded in two ways. One is through using CGAfflineTransformIdentity and another just by pushing the ViewController using CGAffineTransformMakeTranslation.
The Apple documentation describes CGAfflineTransformIdentity as a unit identity matrix. How does my animation happen while I transform my view with identity matrix?
In real math while I multiply some thing with unit matrix I get the same matrix as a result.
So how does the transition really happen with CGAfflineTransformIdentity?
func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
let container = transitionContext.containerView()
let fromView = transitionContext.viewForKey(UITransitionContextFromViewKey)!
let toView = transitionContext.viewForKey(UITransitionContextToViewKey)!
let offScreenUp = CGAffineTransformMakeTranslation(0, -container.frame.size.height )
let offScreenDown = CGAffineTransformMakeTranslation(0, 0)
toView.transform = offScreenUp
container.addSubview(fromView)
container.addSubview(toView)
let duration = self.transitionDuration(transitionContext)
UIView.animateWithDuration(duration, delay: 0.0, usingSpringWithDamping: 1.0, initialSpringVelocity: 0.8, options: nil, animations: {
toView.transform = CGAffineTransformIdentity
//toView.transform = offScreenDown
}, completion: { finished in
// tell our transitionContext object that we've finished animating
transitionContext.completeTransition(true)
})
}