I am still really at the beginning of learning swift and making app. So I already apologize because my problem might be really obvious but I couldn't fix it with every research made for few days. I made a small app with few views embedded in a navigation controller. It works well when I use default segues (show or present modally). But I wanted to improve it by making and using a custom segue. I made the class and used it between views embedded in the NavigationVC. Then it doesn't work. When I press button in the view nothing happen. The problem do not seems to come from the custom segue because it works well when used between view not embedded in NVC. So it might be a more fundamental problem of using custom segue within NVC. Is that not possible ? Or maybe the code may be modified for views within navigation stack. Here the custom segue :
class CustomSegueRotation : UIStoryboardSegue {
override func perform() {
let initialViewController = self.source.view
let destinationViewController = self.destination.view
let rotation = CAKeyframeAnimation (keyPath: "transform.rotation.y")
rotation.values = [0, CGFloat.pi]
rotation.autoreverses = false
initialViewController?.addSubview(destinationViewController!)
UIView.animate(withDuration: 0.3, delay: 0.05, options: .curveEaseInOut, animations: {
initialViewController?.layer.add(rotation, forKey: nil)
}, completion: nil)
}}
Thank you very much for the help.