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