@moni15, I was trying to debug view hierarchy before but there's no black artifacts visible, also when I'm turning on view frames everything is looking fine. This looks like some rendering problem, or maybe iOS bug ?
Here's code for Presentation and Dimiss transition :
class TransitionPresentationAnimator: NSObject, UIViewControllerAnimatedTransitioning {
func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
return 0.3
}
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
let toViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)!
let containerView = transitionContext.containerView
let animationDuration = self .transitionDuration(using: transitionContext)
toViewController.view.transform = CGAffineTransform(scaleX: 0.1, y: 0.1)
toViewController.view.layer.shadowColor = UIColor.black.cgColor
toViewController.view.layer.shadowOffset = CGSize(width: 0.0, height: 2.0)
toViewController.view.layer.shadowOpacity = 0.3
toViewController.view.layer.cornerRadius = 4.0
toViewController.view.clipsToBounds = true
containerView.addSubview(toViewController.view)
UIView.animate(withDuration: animationDuration, animations: { () -> Void in
toViewController.view.transform = CGAffineTransform.identity
}, completion: { (finished) -> Void in
transitionContext.completeTransition(finished)
})
}
}
class TransitionDismissAnimator : NSObject, UIViewControllerAnimatedTransitioning {
func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
return 0.3
}
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
let fromViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)!
let animationDuration = self .transitionDuration(using: transitionContext)
UIView.animate(withDuration: animationDuration, animations: { () -> Void in
fromViewController.view.alpha = 0.0
fromViewController.view.transform = CGAffineTransform(scaleX: 0.1, y: 0.1)
}) { (finished) -> Void in
transitionContext.completeTransition(!transitionContext.transitionWasCancelled)
}
}
}
Solved ! Problem was in TransitionPresentationAnimator class, and CGAffineTransform which was doing something wrong. Now I'm not using it anymore. I'm pasting my code if anyone will have similiar problem :
class TransitionPresentationAnimator: NSObject, UIViewControllerAnimatedTransitioning {
func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
return 0.3
}
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
to = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)!
from = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)!
let container = transitionContext.containerView
container.addSubview(to.view)
to.view.bounds.origin = CGPoint(x: 0, y: -from.view.bounds.size.height)
UIView.animate(withDuration: 0.6, delay: 0.0, usingSpringWithDamping: 0.6, initialSpringVelocity: 0, options: [.curveEaseOut], animations: {
self.to.view.bounds = self.from.view.bounds
}) { (completed) in
transitionContext.completeTransition(completed)
}
}
}