【问题标题】:Opening a curtain: Animation with Core Animation拉开帷幕:Core Animation 的动画
【发布时间】:2011-03-08 20:57:25
【问题描述】:

我想为打开的窗帘制作动画。我有两张图片:一张用于左侧,一张用于右侧窗帘(用红色表示)。我想用 Core Animation 顺利地将它们滑开。我应该寻找什么动画类型?如何实现逼真的滑动样式?

问候,

斯蒂芬

alt text http://img.skitch.com/20100627-8ytxrbe64ccbruj49c2pbs7kt2.png

【问题讨论】:

    标签: iphone cocoa-touch animation core-animation


    【解决方案1】:

    男人

    经过长时间的搜索。我能找到的唯一方法就是这个。

    https://github.com/Ciechan/BCMeshTransformView

    【讨论】:

      【解决方案2】:

      我不确定为什么人们建议使用翻译。如果您需要做的只是滑动图像,只需在动画块内的每个图像视图上调用 -setCenter。像这样:

      [UIView beginAnimations:nil context:NULL];
      [UIView setAnimationDuration:1.0];
      [leftCurtainImageView setCenter:pointOffScreenLeft];
      [rightCurtainImageView setCenter:pointOffScreenRight];
      [UIView commitAnimations];
      

      pointOffScreenLeft 和 pointOffScreenRight 的计算方式如下:

      CGPoint pointOffScreenLeft = CGPointMake(
                       -[leftCurtainImageView bounds].size.width, 
                       [leftCurtainImageView frame].origin.y);
      
      CGPoint pointOffScreenRight = CGPointMake(
                       [rightCurtainImageView frame].origin.x + 
                       [rightCurtainImageView bounds].size.width, 
                       [leftCurtainImageView frame].origin.y);
      

      这些计算假设窗帘分别位于其包含视图的最左侧和最右侧边缘。

      【讨论】:

        【解决方案3】:

        最简单的解决方案是必须使用 imageview 或 CGLayers,然后在动画块中使用 CGAffineTransformTranslate 将它们滑出屏幕。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2012-04-27
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2011-07-12
          • 2017-05-28
          相关资源
          最近更新 更多