2015-04-28 9 views
6

Miałem następujące niestandardowe przejście przy użyciu UIView.animateWithDuration(...usingSpringWithDamping:...), które działało idealnie.iOS: springWithDamping like animacja dla animacji KeyFrame

UIView.animateWithDuration(self.transitionDuration(transitionContext), 
    delay: 0.0, usingSpringWithDamping: 0.8, initialSpringVelocity: 1.0, 
    options: nil, animations: {() in 
    // ... 
}, completion: {(Bool) in 
    // ... 
}) 

Ale wtedy miałem przedłużyć swój własny przejście z UIViewControllerInteractiveTransitioning aby mieć interaktywny przejścia, gdzie użytkownik może ponownie przesuń w dół modalne widoku.

Dlatego potrzebowałem klatek kluczowych do animacji, aby UIPercentDrivenInteractiveTransition działał poprawnie.

Więc zmieniłem funkcję animacji, aby użyć UIView.animateWithKeyframes....

UIView.animateKeyframesWithDuration(self.transitionDuration(transitionContext), 
    delay: 0.0, options: UIViewKeyframeAnimationOptions.CalculationModeCubic, 
    animations: {() in 
    // ... 
}, completion: {(Bool) in 
    // ... 
}) 

Mój problem teraz: Straciłem animację wiosny.

Sprawdziłem kilka linków, jeden z najbardziej obiecujących było:

... ale z .addKeyframes... metody nie mogę określić blok ukończenia że muszę.

Wszelkie sugestie? : -/

+0

pan spojrzeć na https://github.com/felixjendrusch/Marionette? – Eran

+0

odłóż na bok, sprawdź ten post na wiosennych animacjach https://medium.com/@flyosity/your-spring-animations-are-bad-and-it-s-probably-apple-s-fault-784932e51733 –

Odpowiedz

0

Spróbuj tego:

UIView.animateKeyframesWithDuration(self.transitionDuration(transitionContext), 
    delay: 0.0, options: UIViewKeyframeAnimationOptions.CalculationModeCubic, 
    animations: {() in 
     UIView.addKeyframeWithRelativeStartTime(0.0, 
      relativeDuration:0.5, 
      animations: {() in 
       // first animation 
     })  
     UIView.addKeyframeWithRelativeStartTime(0.5, 
      relativeDuration:0.5, 
      animations: {() in 
       // spring animation 
     }) 
}, completion: {(Bool) in 
    // cleaning 
}) 
Powiązane problemy