17. Small item: Tom Cat version 3.0

Source: Internet
Author: User

------------- viewcontroller.m -------------

#import "ViewController.h"


@interface viewcontroller ()

@property (weak, nonatomic) iboutlet uiimageview *imageview;

-(ibaction) drink;

-(ibaction) konckout;

-(ibaction) footleft;

@end


@implementation Viewcontroller

-(ibaction) drink

{

    [ Self Playanimationwithimagename: Span style= "font-variant-ligatures:no-common-ligatures; Color: #d12f1b ">@" Drink " andimagecount: 81 ";

}

-(ibaction) konckout

{

    [ Self Playanimationwithimagename: Span style= "font-variant-ligatures:no-common-ligatures; Color: #d12f1b ">@" Knockout " andimagecount: 81 ";

}

-(ibaction) footleft

{

    [ Self Playanimationwithimagename: Span style= "font-variant-ligatures:no-common-ligatures; Color: #d12f1b ">@" Footleft " andimagecount: 30 ";

}

-(void) Playanimationwithimagename: (nsstring *) imageName andimagecount: (nsinteger) Count

{

if(self. ImageView . Isanimating)

{

return;

}

nsmutablearray *images = [nsmutablearray array];

for (int i = 0; i < count; i++)

{

nsstring *name = [ nsstring stringwithformat : @ "%@_%02d.jpg" , imagename,i];

nsstring *path = [[ nsbundle mainbundle ] Pathforresource : Name oftype : nil ];

UIImage *image = [UIImage imagewithcontentsoffile:p Ath];

[Images AddObject: image];

}

Self. ImageView. animationimages = images;

Self. ImageView. animationduration = 0.05 * count;

    Self . imageview Animationrepeatcount = 1 ;

[self. ImageView startanimating];

you need to clear animationimages when the animation has finished playing

// the first way:

    [ Self Performselector:@selector(clearimages)Withobject:Nil Afterdelay: Self.ImageView.animationduration];

// second Way

[Self.imageview performselector: @selector (setanimationimages:) Withobject:nil Afterdelay: Self.imageView.animationDuration];

// Third Way

Dispatch_after (Dispatch_time (Dispatch_time_now, (int64_t) (Self.imageView.animationDuration * nsec_per_sec)), Dispatch_get_main_queue (), ^{

Self.imageView.animationImages = nil;

//    });

}

-(void) clearimages

{

self. ImageView . Animationimages = nil;

}

@end


17. Small item: Tom Cat version 3.0

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.