2013-01-02 70 views
-2

我不知道如何制作动画,或者我会如何将它放入Xcode。有人可以给我一些关于这方面的背景资料吗?如何将动画添加到Xcode中?

+0

http://stackoverflow.com.tw m/questions/630265/iphone-uiview-animation-best-practice –

+0

尝试使用Google。 “Xcode动画”。有很多关于它的信息。 –

+0

http://www.apeth.com/iOSBook/ch17.html – matt

回答

5
NSArray *animationArray = [NSArray arrayWithObjects:[UIImage [email protected]"firstImage",[UIImage [email protected]"secondImage",nil]; //add as many as you want 

现在你需要一个imageview的设置动画:

self.myImageView.animationImages =animationArray; 
self.myImageView.animationDuration = 3; 
self.myImageView.animationRepeatCount = -1; //keeps going infinitely 

[self.myImageView startAnimating]; 
0

我猜你想要做的是创建一个动画图像,而不是动画化一个视图过渡...这里有两个创建iOS动画的方法背景。

第一个选项:创建图像数组(UIImage),然后使用startAnimating方法。 事情是这样的:

imageView.image = yourLastImage; 
// Do this first so that after the animation is complete the image view till show your last image. 

NSArray * imageArray = [[NSArray alloc] initWithObjects: 
[UIImage imageNamed:@"image1.png"], 
[UIImage imageNamed:@"image2.png"], 
[UIImage imageNamed:@"image3.png"],       
[UIImage imageNamed:@"image4.png"], 
nil]; 

// Note: here you may instead want to use something like [UIImage imageWithContentsOfFile:[self localImagePath:NO]] instead depending upon your targeted iOS version. 



UIImageView * animatedImageView = [[UIImageView alloc] initWithFrame: 
     CGRectMake(100, 125, 150, 130)]; 
    animatedImageView.animationImages = imageArray; 
    animatedImageView.animationDuration = 1.1; 
     myAnimation.animationRepeatCount = 1; 
    animatedImageView.contentMode = UIViewContentModeBottomLeft; 

    [self.view addSubview:animatedImageView]; 
    [animatedImageView startAnimating]; 

第二个选项:(适用于iOS 4及更高版本)可以使用基于块的方法。这里是一个指向StackOverflow的参考文章的链接。

What are block-based animation methods in iPhone OS 4.0?

你也可能想看看,苹果提供与核心动画文件:

http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/CoreAnimation_guide/Articles/AnimatingLayers.html#//apple_ref/doc/uid/TP40006085-SW1