如何创build一个移动的图像

我如何创build一个移动到屏幕上的图像? 所以它从底部出现,当完全可见时停止。 我也会玩速度和方向。 这不像Apple的PhotosSroller示例所示的照片滚动

CGRect endFrame = [[self view] frame]; [imageView setFrame: CGRectMake([[self view] frame].origin.x, [[self view] frame].origin.y + 480.0, [[self view] frame].size.width, [[self view] frame].size.height)]; [UIView beginAnimations: nil context: NULL]; [UIView setAnimationDuration: 0.25]; [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut]; [imageView setFrame: endFrame]; [UIView commitAnimations]; 

它没有testing,但会给你一个想法。

更新:

为了animation块

 [imageView setFrame: CGRectMake([[self view] frame].origin.x, [[self view] frame].origin.y + 480.0, [[self view] frame].size.width, [[self view] frame].size.height)]; [UIView animateWithDuration: 1.0f animations: ^{ [imageView setCenter: [[self view] center]]; } ]; 

你可以通过反转来隐藏imageView。

(y)0 – imageView height = top
(x)0 – imageView width = left
[self view] height = bottom
[self view] width = right

再次没有testing,但会给你一个想法如何使用它。

看看UIViewanimateWithDuration:方法。 你基本上改变了框架,该方法将animation视图的移动。 这很简单,只需阅读文档。 如果你需要任何帮助,请不要犹豫。

如果我明白你想要达到什么目的,你应该能够通过animation属性(例如图像视图的位置和alpha)来获得你正在寻找的UIViewanimation的结果。 例如,如果你有一个完全透明的视图,你想要移动到你的视图控制器视图的中心,你可以这样做:

 [UIView animateWithDuration: 0.25 animations: ^{ imageView.center = self.view.center; imageView.alpha = 1.0f; }