IOS Tom Cat Code

Source: Internet
Author: User

mjviewcontroller.m//03-tom////Created by Apple on 13-11-24.//Copyright (c) 2013 itcast. All rights reserved.//#import "MJViewController.h" @interface Mjviewcontroller () {nsdictionary *_dict;//Save the number of all pictures}@e        Nd@implementation mjviewcontroller-(void) viewdidload {[Super viewdidload];    1. Obtain the full path of the tom.plist nsbundle *bundle = [NSBundle mainbundle];        NSString *path = [Bundle pathforresource:@ "Tom" oftype:@ "Plist"]; 2. Load the dictionary according to the file path _dict = [Nsdictionary dictionarywithcontentsoffile:path];} -(void) Playanim: (int) Count Fliename: (NSString *) filename {//1. Create variable array nsmutablearray *images = [Nsmutablearray arr        AY]; 2. Add picture for (int i = 0; i<count; i++) {//Picture name nsstring *name = [NSString stringwithformat:@]%@_%02d        . jpg ", filename, I];                Full path NSString *path = [[NSBundle mainbundle] Pathforresource:name Oftype:nil];        Load picture (cache)//UIImage *img = [UIImage imagenamed:name];       No cache UIImage *img = [[UIImage alloc] initwithcontentsoffile:path];    [Images addobject:img];        }//3. Set animated picture (in order) _tom.animationimages = images;//sequence frame animation//4. Play only once _tom.animationrepeatcount = 1;        5. Set the duration of the animation _tom.animationduration = 0.1 * count; 5. Start the animation [_tom startanimating];}        #pragma mark listens to all button clicks-(ibaction) Btnclick: (UIButton *) Sender {//1. If Tom is playing the animation, return directly to the IF (_tom.isanimating) return;        2. Remove the button text nsstring *title = [Sender titleforstate:uicontrolstatenormal];        3. Get the number of images int count = [_dict[title] intvalue]; 4. Play the animation [self Playanim:count fliename:title];} @end

  

IOS Tom Cat Code

Related Article

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.