0

我有一个简单的图像,我想在上下动画...我如何在 iPhone 应用程序中实现它?

请帮忙

谢谢

4

2 回答 2

2

您可以使用一组图像并在 1 个 UIImage 中为它们设置动画:

iOS 5:

@interface UIImage (WrightsCS)
+(UIImage *)animatedImageWithImages:(NSArray *)images duration:(NSTimeInterval)duration;
@end

if ( SYSTEM_VERSION_GREATER_THAN(@"5.0") )
{
    NSArray *animationFrames = [NSArray arrayWithObjects:
                                [UIImage imageNamed:@"image_0.png"],
                                [UIImage imageNamed:@"image_1.png"],
                                [UIImage imageNamed:@"image_3.png"],
                                [UIImage imageNamed:@"image_4.png"], nil];

    UIImage * animatedImage = [UIImage animatedImageWithImages:animationFrames duration:2.0f];    
} 
于 2012-03-09T04:18:30.807 回答
0

你看过任何核心动画文档吗?

我要做的是创建一个 CALayer,将图像添加到其内容中。将其放置在视图之外。将其作为子层添加到 UIView 的层,然后将此层的位置设置为您希望它动画到的位置。

这应该给你足够的提示来开始。当你掌握了窍门时,你可以看看做更复杂的动画。

于 2012-03-09T04:18:21.120 回答