I make dropping down animation for changing views. When I use POPSpringAnimation
all working correctly. But when I change POPSpringAnimation
to POPDecayAnimation
nothing happens and in debug output I see this message:
ignoring to value on decay animation <POPDecayAnimation:0x7f9f2b5c8700; from = null; to = null; deceleration = 0.998000>
Code:
func switchViewController(from: UIViewController?, toViewController to: UIViewController?, animated: Bool) {
if animated {
to!.view.frame = self.view.frame
// Not working when call trulySwitchViewController
self.addChildViewController(to!)
self.view.insertSubview(to!.view, belowSubview: from!.view)
to!.didMoveToParentViewController(self)
// Calculate new x coord
var frame = from!.view.frame
frame.origin.y += frame.size.height
// POPDecayAnimation not working here
var animation = POPDecayAnimation()
animation.property = POPAnimatableProperty.propertyWithName(kPOPViewFrame) as POPAnimatableProperty
animation.toValue = NSValue(CGRect:frame)
animation.completionBlock = {
(_, _) in
self.trulySwitchViewController(from, toViewController: nil)
}
from!.view.pop_addAnimation(animation, forKey: "dropDown")
} else {
to?.view.frame = self.view.frame
self.trulySwitchViewController(from, toViewController: to)
}
}