17.小项目:汤姆猫 版本3.0

@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);

-------------  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:@"drink" andImageCount:81];

}

- (IBAction)konckOut

{

[self playAnimationWithImageName:@"knockout" andImageCount:81];

}

- (IBAction)footLeft

{

[self playAnimationWithImageName:@"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:path];

[images addObject:image];

}

self.imageView.animationImages = images;

self.imageView.animationDuration = 0.05 * count;

self.imageView.animationRepeatCount = 1;

[self.imageView startAnimating];

//  当动画播放完毕需要清除animationImages

//  第一种方式:

[self performSelector:@selector(clearImages) withObject:nil afterDelay:self.imageView.animationDuration];

//  第二种方式

//  [self.imageView performSelector:@selector(setAnimationImages:) withObject:nil afterDelay:self.imageView.animationDuration];

//  第三种方式

//  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

@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);

时间: 2024-12-19 00:10:33

17.小项目:汤姆猫 版本3.0的相关文章

15.小项目:汤姆猫 版本1.0

-------------  ViewController.m  ------------- #import "ViewController.h" @interface ViewController () @property (weak, nonatomic) IBOutlet UIImageView *imageView; - (IBAction)drink; - (IBAction)konckOut; - (IBAction)footLeft; @end @implementati

16.小项目:汤姆猫 版本2.0

-------------  ViewController.m  ------------- #import "ViewController.h" @interface ViewController () @property (weak, nonatomic) IBOutlet UIImageView *imageView; - (IBAction)drink; - (IBAction)konckOut; - (IBAction)footLeft; @end @implementati

24.小项目:应用市场 版本7.0

@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css); ------------- CZapp.h ------------- #import <Foundation/Foundation.h> @interface CZApp : NSObject @property (nonatomic,copy) NSSt

22.小项目:应用市场 版本5.0

------------- CZapp.h ------------- #import <Foundation/Foundation.h> @interface CZApp : NSObject @property (nonatomic,copy) NSString *name; @property (nonatomic,copy) NSString *icon; - (instancetype) initWithDict:(NSDictionary *) dict; + (instancet

25.小项目:应用市场 版本8.0

------------- CZapp.h ------------- #import <Foundation/Foundation.h> @interface CZApp : NSObject @property (nonatomic,copy) NSString *name; @property (nonatomic,copy) NSString *icon; - (instancetype) initWithDict:(NSDictionary *) dict; + (instancet

26.小项目:应用市场 版本9.0

------------- CZapp.h ------------- #import <Foundation/Foundation.h> @interface CZApp : NSObject @property (nonatomic,copy) NSString *name; @property (nonatomic,copy) NSString *icon; - (instancetype) initWithDict:(NSDictionary *) dict; + (instancet

23.小项目:应用市场 版本6.0

@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css); @import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css); ------------- C

13.小项目:图片浏览器 版本3.0

---------------  ViewController.m  --------------- #import <Foundation/Foundation.h> #import "ViewController.h" @interface ViewController () @property (weak, nonatomic) IBOutlet UILabel *indexLabel; @property (weak, nonatomic) IBOutlet UII

12.小项目:图片浏览器 版本3.0

@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css); ---------------  ViewController.m  --------------- #import <Foundation/Foundation.h> #import "ViewController.h" @interf