Mal*_*eur 18
首先,apple doc是你的朋友.我在这里给你的所有信息都来源于此.Apple还提供了大量示例代码,您一定要看看它.
您可以(轻松)实现此目的的方法是使用UIView动画.假设您的图像具有UIImageView,则可以使用该animateWithDuration:(NSTimeInterval)duration animations:...方法.
例如:
[UIView animateWithDuration:10.0f animations:^{
//Move the image view to 100, 100 over 10 seconds.
imageView.frame = CGRectMake(100.0f, 100.0f, imageView.frame.size.width, imageView.frame.size.height);
}];
Run Code Online (Sandbox Code Playgroud)
您可以通过添加更多的选项动画,让完成块等,这都与"animateWithDuration"方法的变化实现更大胆的尝试.有很多关于UIView动画的教程,还有大量的文档.
如果您不想使用块(上面的^ {... code ...}位),您可以像这样运行动画:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:10.0f];
imageView.frame = ...
[UIView commitAnimations];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11619 次 |
| 最近记录: |