Full implementation of frame animations: Direct Code Demo

Source: Internet
Author: User

Full implementation of frame animations:

Directly on the code demo more clearly

1 full code implementation of frame animation:2 #import "ViewController.h"3 @interfaceViewcontroller ()4 5@property (Weak, nonatomic) Iboutlet Uiimageview *Imageviewicon;6 7 @end8 9 @implementationViewcontrollerTen  One //encapsulate the same code. A-(void) Beginanimationwithimagecount: (int) a imageName: (NSString *) ImageName - { - //call the Isanimating method to determine if the animation is in execution, and if you have to perform other animations after you have done so, you have to decide if the if(self.imageViewIcon.isAnimating)return; -  - //1. Set the desired animation image to uiimageview (picture box) -Nsmutablearray *array=[Nsmutablearray array]; +  -  for(intI=0; i<a; i++) { +NSString *image=[nsstring stringWithFormat:@"%@%03d", imagename,i+1]; A  at //UIImage *img=[uiimage Imagenamed:image]; The data that is loaded in this way is cached, - //if created with a path, there is no cache -NSString *img_path=[[nsbundle mainbundle]pathforresource:image OfType:@"PNG"]; -UIImage *img=[uiimage Imagewithcontentsoffile:img_path];// - //Note: If this is not the case when the footage is loaded into supporting files, it will appear empty, so when using the path, add the footage to the supporting files -  in [Array addobject:img]; - } to  + //sets the image array of the animation to be executed to the Animationimages property of the picture frame -self.imageviewicon.animationimages=Array; the  * //2. Set the duration of the animation to perform 0.1 seconds for each picture $self.imageviewicon.animationduration=0.1*Self.imageViewIcon.animationImages.count;Panax Notoginseng  - //3. Set the number of repetitions of the animation theSelf.imageviewicon.animationrepeatcount=1; +  A //4. Start the animation the [Self.imageviewicon startanimating]; +  - //wait for the animation to finish, then clean the memory Performselector:set method Withobject object Afterdelay time $ [Self.imageviewicon performselector: @selector (setanimationimages:) Withobject:nil Afterdelay: Self.imageViewIcon.animationDuration]; $  -}

Full implementation of frame animations: Direct Code Demo

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.