【问题标题】:How to convert a CABasicAnimation to UIView animatewithDuration如何将 CABasicAnimation 转换为 UIView animatewithDuration
【发布时间】:2015-05-06 13:05:06
【问题描述】:

我想将 CABasicAnimation 转换为 UIView animatewithDuration ,如果有可能吗?

这是我目前尝试过的代码

CABasicAnimation *myAni = [CABasicAnimation animationWithKeyPath:@"transform.scale.x"];
myAni.duration = 2.0f;
myAni.fromValue = [NSNumber numberWithFloat:1.0];
myAni.toValue = [NSNumber numberWithFloat:2.0];

[self.myView addAnimation:scaleAnimation forKey:@"myKey"];

加入[UIView animateWithDuration...。 (而不是 CABasicAnimation,我希望它在 animations 块中的 animationWithDuration 中。)

这可能吗?如果有,怎么做?

[UIView animateWithDuration:0.5
                      delay:1.0
                    options: UIViewAnimationCurveEaseOut
                 animations:^{
                     //I need it here
                 } 
                 completion:^(BOOL finished){

                 }];

提前致谢

【问题讨论】:

    标签: ios objective-c animation cabasicanimation animatewithduration


    【解决方案1】:
      [UIView animateWithDuration:0.5
                              delay:1.0
                            options: UIViewAnimationOptionCurveEaseInOut
                         animations:^{
                             //self.myView.transform = CGAffineTransformMakeScale(2.0,1.0);
                         self.testview.layer.transform = CATransform3DMakeScale(2.0,1.0,1.0);
    
                         }
                         completion:^(BOOL finished){
    
                         }];
    

    【讨论】:

    • 如何改用 CATransform?
    • CATransform instead 是什么意思?
    • 我不想使用CGAffinTransformMakeScale,而是使用CATransform3DMakeScale
    • 其实没关系。我知道了。另外,是否可以在完成块中有另一个 animateWithDuration ?
    • 查看更新,只需设置图层的变换即可。您可以在完成块中启动动画
    猜你喜欢
    • 1970-01-01
    • 2011-07-25
    • 2015-08-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-23
    • 2023-04-09
    相关资源
    最近更新 更多