I don't know how to make an animation, or how I would put that into Xcode. Can someone just give me a little background info on this?
Asked
Active
Viewed 5,772 times
-2
-
http://stackoverflow.com/questions/630265/iphone-uiview-animation-best-practice – Robot Woods Jan 02 '13 at 21:28
-
try using Google. "Xcode animation". There's tons and tons of info about it. – Mike M Jan 02 '13 at 21:43
-
http://www.apeth.com/iOSBook/ch17.html – matt Jan 02 '13 at 22:06
-
What does this have to do with Xcode? You want to put the animation in your iOS app, not Xcode, correct? What kind of animation? Your question is far too vague to answer. – rmaddy Jan 02 '13 at 22:16
2 Answers
5
NSArray *animationArray = [NSArray arrayWithObjects:[UIImage imageNamed@"firstImage",[UIImage imageNamed@"secondImage",nil]; //add as many as you want
Now you need an imageview to set the animation to:
self.myImageView.animationImages =animationArray;
self.myImageView.animationDuration = 3;
self.myImageView.animationRepeatCount = -1; //keeps going infinitely
[self.myImageView startAnimating];

Makleesh
- 988
- 10
- 15
0
I am guessing that what you want to do is to create an animated image, rather than animate a view transition... Here is a little background on two ways of creating an animation for iOS.
First option: Create an array of Images (UIImage), then use the startAnimating method. Something like this:
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];
Second Option: (for iOS 4 and later) You can use block-based methods. Here is a link to a reference article for this here on StackOverflow.
What are block-based animation methods in iPhone OS 4.0?
Also you may want to take a look at the documentation that Apple provides relating to Core Animation:

Community
- 1
- 1

ciara staggs
- 329
- 2
- 7