2010-06-27 72 views

回答

1

的最简单的解决办法是有向的ImageView或CGLayers然后使用CGAffineTransformTranslate在动画block滑动它们关闭屏幕。

5

我不确定为什么人们建议使用翻译。如果您只需滑动图像,只需在动画块内的每个图像视图上调用-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); 

上述计算假设窗帘分别位于最左边和最右边的边包含它们的看法。