How do I animate the presentation movement in iOS?

I am a very beginner programmer and I am trying to find the easiest way to do this. I’ve never done anything with animation before. I want to try image animation in my application and I am having some problems. This is the code previously suggested to be used (on another issue):

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]; 

Well, firstly, is it even practical? I want to animate something that goes from the middle of the screen to the bottom of the screen. Does this mean that I should have 500 images, each 1 pixel apart? What is the optimal pixel spacing so that it looks fluid and doesn't even require a ton of work? Is there a better way to animate than higher? Is there a program that helps you create animations that you can later add to Xcode?

Also, can someone explain the code above? I am new to animation, I don’t quite understand what all this means.

Sorry if this is a stupid question, I said at the opening that I am new. Thanks for any help you can provide!

+8
arrays ios objective-c xcode animation
source share
2 answers

For most animations, you can simply change the view properties inside the UIView animation UIView . The documentation for the UIView class lists properties that are animated.

 [UIView animateWithDuration:0.5f animations:^{ aView.frame = CGRectOffset(aView.frame, 0, 250); }]; 

Here is an example project demonstrating how you will start the animation when you click a button. You can put this animation code in many other places, so there is no good answer to your question about where to put the code if you do not give more detailed information about what you want.

https://github.com/MaxGabriel/AnimationDemonstration

The approach you took was the UIImageView animation. I have never done this, but I understand that how to make an animated GIF. For things like moving views or fading, you need to use the animation block method shown above.

+27
source share

Simple animation in iOS.

 CGRect basketTopFrame = self.upperview.frame; basketTopFrame.origin.y = -basketTopFrame.size.height; CGRect basketBottomFrame = self.lowerview.frame; basketBottomFrame.origin.y = self.view.bounds.size.height; [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:1.0]; [UIView setAnimationDelay:1.0]; [UIView setAnimationCurve:UIViewAnimationCurveEaseOut]; self.upperview.frame = basketTopFrame; self.lowerview.frame = basketBottomFrame; [UIView commitAnimations]; 
+1
source share

All Articles