ios - UIView组动画

标签 ios animation core-animation uiviewanimation

我正在尝试实现以下动画:

    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/

相关文章:

objective-c - 为圆圈上的刻度制作动画以保持中心位置

iphone - UIScrollView - 一种使一个 ScrollView 小于另一个 ScrollView 的方法?

ios - MacOS High Sierra 升级后 Xcode Server Gym 失败

ios - 我正在用 Objective C 创建一个框架,它需要一个好的构造函数模式

ios - 使用延迟动画暂停 CALayer 动画

android - 如何在android中将图像从左向右移动

python - 更新 python 动画时删除先前的散点图

ios - 单元格高度 : Thread 1: Fatal error: Index out of range when pulling up data in UITableView

ios - View Controller 在 Storyboard 初始 View Controller 更改中丢失了 unwind segue

Android:在 FrameLayout 中翻译动画后无法单击底部的 TextView