我想在多维数据集上提供我的项目customsegue效果。 UIStoryboard认为这段代码。然而,立方体效应不会发生。我想知道我哪里出错了?
import UIKit
import QuartzCore
class CubeSegue: UIStoryboardSegue {
override func perform() {
let source:UIViewController = self.sourceViewController as UIViewController
let destination:UIViewController = self.destinationViewController as UIViewController
let transition = CATransition()
transition.type = "cube"
transition.duration = 0.5
transition.subtype = kCATransitionFromRight
transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear)
self.sourceViewController.navigationController!!.pushViewController(self.destinationViewController as UIViewController, animated: true)
IS}
}
感谢您的帮助。
答案 0 :(得分:0)
我需要以这种方式编写代码..
override func perform() {
let source = self.sourceViewController as UIViewController;
let destination = self.destinationViewController as UIViewController;
let animation = CATransition()
animation.type = "cube"
animation.duration = 0.5
animation.subtype = kCATransitionFromRight
animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear)
source.navigationController?.view.layer.addAnimation(animation, forKey: kCATransition);
source.navigationController?.pushViewController(destination, animated: true);
}
}