简体   繁体   English

向UIView animateKeyframesWithDuration添加缓动

[英]Add easing to UIView animateKeyframesWithDuration

Im using 我正在使用

UIView animateKeyframesWithDuration

and i have 3 animation sections using 我有3个动画部分使用

[UIView addKeyframeWithRelativeStartTime

However, on one of the key frames I want to easeIn. 但是,在其中一个关键帧上,我想要EasyIn。

How can I add an easing function to this? 如何为此添加缓动功能?

Here is a trustworthy article: https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/Animation_Types_Timing/Articles/Timing.html You will have to deal with CAAnimation , not just UIView . 这是一篇值得信赖的文章: https : //developer.apple.com/library/ios/documentation/Cocoa/Conceptual/Animation_Types_Timing/Articles/Timing.html您将不得不处理CAAnimation ,而不仅仅是UIView

Update: As the PO didn't make it so far, there are some catches on what could go wrong: a) Make sure that your animation is created and added like follows: 更新:由于PO到目前为止还没有做到,所以有一些问题可能会导致: a)确保创建并添加了动画,如下所示:

CABasicAnimation* fadeAnim = [CABasicAnimation animationWithKeyPath:@"opacity"];
fadeAnim.fromValue = [NSNumber numberWithFloat:1.0];
fadeAnim.toValue = [NSNumber numberWithFloat:0.0];
fadeAnim.duration = 1.0;
[theLayer addAnimation:fadeAnim forKey:@"opacity"];

// Change the actual data value in the layer to the final value.
theLayer.opacity = 0.0;

For more details see: https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CoreAnimation_guide/CreatingBasicAnimations/CreatingBasicAnimations.html 有关更多详细信息,请参见: https : //developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CoreAnimation_guide/CreatingBasicAnimations/CreatingBasicAnimations.html

b) When you use animateTransition: , make sure that : b)使用 animateTransition: ,请确保

All animations must take place in the view specified by the containerView property of transitionContext. 所有动画都必须在transitionContext的containerView属性指定的视图中进行。

(visit https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewControllerAnimatedTransitioning_Protocol/#//apple_ref/occ/intfm/UIViewControllerAnimatedTransitioning/animateTransition : for reference). (请访问https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewControllerAnimatedTransitioning_Protocol/#//apple_ref/occ/intfm/UIViewControllerAnimatedTransitioning/animateTransition :以供参考)。 Hope this will help you sort all the issues out. 希望这可以帮助您解决所有问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM