animation - iOS5将CGAffineTransform与animationImages结合起来?

标签 animation ios5 uiimageview uiimage cgaffinetransform

我对 iOS 动画还很陌生,我想知道是否可以使用 CGAffineTransform 将两个图像之间的过渡与 UIImageView 的平移动画结合起来?

换句话说,我想在两个图像之间设置动画,然后我想应用同步翻译,以便整个内容在页面上移动,同时在两个图像之间来回移动。

我知道我可以申请CGAffineTransformConcat组合两个 CGAffineTransform,例如 CGAffineTransformTranslate还有其他的东西。但我没有看到 CGAffineTransform 允许我转换到另一个 UIImage。

我知道在图像之间制作动画的唯一方法是使用 UIImageView animationImages array 与 startAnimating 结合。但是,我不知道如何将其与这样的翻译结合起来:

UIImageView* textView = [[UIImageView alloc] initWithFrame:bunnyImage.frame]; 

textView.animationImages = [NSArray arrayWithObjects:    
                            [UIImage imageNamed:@"bunnyclose.png"],
                            [UIImage imageNamed:@"bunnytalk.png"],
                            nil];

textView.animationDuration = 1.0;
textView.animationRepeatCount = 8;
[textView startAnimating];

[self.view addSubview:textView];    

有什么建议吗?

最佳答案

回答我自己的问题, block 动画函数 transitionFromView:toView:duration:options:completion"Creating Animated Transitions Between Views" 中所述是我目前想出的最好的解决方案。我用它在图像之间制作动画,并且可以与 block 动画 animateWithDuration:delay:options:animations:completion: 结合使用。使用 CGAffineTransformTranslate 或简单地更改 center Animations 中讨论的 UIImageView .

重新设计我的原始代码块并添加我的翻译,如下所示:

UIImageView* bunny2View = [[UIImageView alloc] initWithFrame:bunny2Image.frame]; 


[UIView 
 transitionFromView:bunny2Image 
 toView:bunny2View 
 duration:10.0 
 options:UIViewAnimationOptionShowHideTransitionViews 
 completion:^(BOOL finished) {
     [UIView 
      animateWithDuration:dur 
      animations:^(void) {
          CGPoint center = bunny2Image.center;
          center.y += deltay;
          bunny2Image.center = center;
          bunny2View.center = center;
      }
      completion:^(BOOL finished) {

          [UIView 
           transitionFromView:bunny2View 
           toView:bunny2Image 
           duration:10.0 
           options:UIViewAnimationOptionShowHideTransitionViews 
           completion:nil];
      }];
 }]; 

仍在进行中,但这就是我到目前为止所想出的!

关于animation - iOS5将CGAffineTransform与animationImages结合起来?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10194724/

相关文章:

javascript - Angular 动画 : on click

iphone - 核心图 : Updating X Axis range in real time plotting

ios - 拖动图像以适合正确的边界框

ios - 使用 WatchKit 以编程方式设置 UIImage 动画

javascript - 如何为 jQuery 中的每个数组元素附加不同的动画效果?并使用 2 个按钮(下一个)一个一个地向前和向后设置动画?

ios - 使用自定义动画关闭 View Controller ?

objective-c - iOS5 中的 Youtube - 点击完成按钮

ios - 在iOS中使用commoncrypto解密mp3文件(mp3文件使用openssl加密)

ios - 在 UIImageView 中延迟加载图像

iphone - UIImage View 动画从一个图像到下一个