Learn the one-hour Tom Cat games, mainly to learn Uiimageview animation properties, now record the new learning to the point of knowledge.
The main points of knowledge are:
Various animation method settings for 1.UIImageview
2.NSMutableArray
The difference between 3.UIImage imagenamed:imagename and [UIImageimagewithcontentsoffile:p Ath]
Interface is we have played before the Tom Cat game, click on some of its location, will show a different action, which is actually used to uiimageview continuous picture display animation knowledge point, the code is as follows:
#import "ViewController.h" @interface Viewcontroller () @property (weak, nonatomic) Iboutlet Uiimageview *tom;@ End@implementation viewcontroller-(void) Toanimation: (NSString *) animatename count: (int) Count { if ( self.tom.isAnimating) { return; } Nsmutablearray *images = [Nsmutablearray array]; for (int i=0; i<count; i++) { NSString *imagename = [NSString stringwithformat:@ "%@_%02d.jpg", animatename,i]; NSString *path = [[NSBundle mainbundle] Pathforresource:imagename Oftype:nil]; UIImage *image = [UIImage Imagewithcontentsoffile:path]; [Images addobject:image]; } [Self.tom setanimationimages:images]; [Self.tom SetAnimationDuration:images.count * 0.075]; [Self.tom startanimating]; [Self.tom performselector: @selector (setanimationimages:) Withobject:nil afterDelay:self.tom.animationDuration];} -(Ibaction) Drink: (ID) Sender { [self toanimation:@ "drink" count:81];} @end
Uiimageview has an array of animation, all we have to do is set up an array of images, and then turn on the Uiimageview animation, while also taking into account memory destruction and so on.
New things to learn:
1.UIImageview Performselector method, when the effect of delay after the animation is finished, destroy the image of the memory-consuming operation.
2.UIImage Imagenamed:imagename Pictures After the use of the finished, will not be destroyed immediately, waiting for the system to be unified destruction, suitable for comparison and less in the entire situation.
[UIImage imagewithcontentsoffile:p Ath], through the path to find pictures, suitable for more than the situation with the picture. First, the name parameter to find the file name, through the name of the file to find the path, the path to initialize the image.
3.NSMutableArray is a subclass of Nsarray, with the Add and delete methods, similar to the list class in Java.
The placeholder for the 4.string type is:%@
iOS Learning 03-making a simple Tom cat