【问题标题】:Opening a curtain: Animation with Core Animation拉开帷幕:Core Animation 的动画
【发布时间】:2011-03-08 20:57:25
【问题描述】:
【问题讨论】:
标签:
iphone
cocoa-touch
animation
core-animation
【解决方案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 将它们滑出屏幕。