我正在尝试实现以下动画:
yourSubView.transform = CGAffineTransformMakeScale(0.01, 0.01);
[UIView animateWithDuration:0.4 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
//change time duration according to requirement
// animate it to the identity transform (100% scale)
yourSubView.transform = CGAffineTransformIdentity;
} completion:^(BOOL finished){
// if you want to do something once the animation finishes, put it here
}];
结合 subview 的一些移动。我知道在核心动画中你可以组合动画,但你如何在 UIView 动画中做到这一点?
我可以将此代码从 UIView 动画转换为 Core 动画吗?
yourSubView.transform = CGAffineTransformMakeScale(0.01, 0.01);
[UIView animateWithDuration:0.4 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
//change time duration according to requirement
// animate it to the identity transform (100% scale)
yourSubView.transform = CGAffineTransformIdentity;
} completion:^(BOOL finished){
// if you want to do something once the animation finishes, put it here
}];
最佳答案
您可以通过更改多个动画属性来组合动画。例如,您还可以设置您的 SubView.alpha,然后更改动画 block 内的 alpha。它将比例和 alpha 变化结合在一起。
要进行简单的翻译,请在您的动画 block 中尝试这样做:
yourSubView.transform = CGAffineTransformTranslate(CGAffineTransformIdentity, 100.0, 100.0);
这应该将比例设置回恒等式,同时在 x 和 y 方向上移动 100px。
对于核心动画,这 Grouping two Core Animations with CAAnimationGroup causes one CABasicAnimation to not run应该让你开始。您将使用 CAAnimationGroup 组合多个动画,并且可以做一些非常奇特的事情,包括 3D 旋转。
缩放:
CAKeyframeAnimation *scale = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
[scale setValues:[NSArray arrayWithObjects:[NSNumber numberWithFloat:0.01f],[NSNumber numberWithFloat:1.0f],nil]];
[scale setKeyTimes:[NSArray arrayWithObjects:[NSNumber numberWithFloat:0.0],[NSNumber numberWithFloat:0.4f],nil]];
[mySubview.layer addAnimation:scale forKey:@"myScale"];
关于ios - UIView组动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12148535/