【问题标题】:CGAffineTransformMakeTranslation: How to apply two animations at onceCGAffineTransformMakeTranslation:如何一次应用两个动画
【发布时间】:2011-10-12 20:54:24
【问题描述】:

我有一个观点,我想通过两种方式进行转换。首先,我想在它的 y 轴上移动它。然后,我想放大它。

但是,当我使用以下代码时,对象会先移动,然后在缩放时移回其原始位置。

有没有办法一次应用两个转换而不取消第一个?

对不起,如果这是基本的,但非常感谢任何帮助!

   [UIView animateWithDuration:animationDuration
                      delay:0
                    options:UIViewAnimationOptionCurveEaseIn
                 animations:^{

                 currentCover.transform = CGAffineTransformMakeTranslation(0, 0-keyboardTop+35);


                 }
                 completion:^(BOOL finished) {


                 [UIView animateWithDuration:animationDuration
                      delay:0
                    options:UIViewAnimationOptionCurveEaseIn
                 animations:^{ 

                 [currentCover setTransform:CGAffineTransformMakeScale (1.3, 1.3)];


                 }
                 completion:^(BOOL finished) { }
 ];



                 }
 ];

【问题讨论】:

    标签: ios cocoa-touch core-animation cgaffinetransform


    【解决方案1】:

    您应该将一个变换乘以另一个变换。每个变换(缩放和平移)都是变换矩阵。要组合它们,只需在使用前一个接一个地进行组合。乘法的顺序决定了应用变换的顺序

    【讨论】:

      【解决方案2】:

      我有类似的问题,我的视图回到原来的位置。

      CGAffineTransformMakeTranslation 中的Documentation 表示“它从 x 和 y 值构造一个新的平移矩阵,指定原点的移动量。”我不认为它适用于实际的转变。

      我认为您宁愿通过调用CGAffineTransformTranslate() 来应用翻译。至少对我有用!!

      【讨论】:

        【解决方案3】:

        在这里,我们正在创建您想要一起执行的两个更改(CGAffineTransform),并将转换应用于视图。

               CGAffineTransform translate = CGAffineTransformMakeTranslation(0, 0-keyboardTop+35);
                CGAffineTransform scale = CGAffineTransformMakeScale(1.3, 1.3);
                CGAffineTransform transform =  CGAffineTransformConcat(translate, scale);
        
            [UIView animateWithDuration: animationDuration
                                      delay:0.0
                                    options:UIViewAnimationOptionCurveEaseIn
                                 animations:^{
                                     currentCover.transform = transform;
                                 }completion:^(BOOL finished){
              }];
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2012-02-09
          • 2011-04-11
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多