Tom-猫

作者: zhangyunjiang | 来源:发表于2016-03-05 18:07 被阅读198次
 #import "ViewController.h"

 @interface ViewController ()
 @property (weak, nonatomic) IBOutlet UIImageView *tom;//tom图片

 - (IBAction)eat;//吃小鸟
 - (IBAction)fart;//放屁
 - (IBAction)drink;//和牛奶
 - (IBAction)scratch;//划玻璃
 - (IBAction)pie;//扔东西
 - (IBAction)cymbal;//敲锣

 - (IBAction)knock;//敲头
 - (IBAction)left;//左脚
 - (IBAction)right;//右脚

 - (IBAction)Angry;//生气
 - (IBAction)Stomach;//胃口
 @end

 @implementation ViewController
 -(BOOL)prefersStatusBarHidden
 {
return YES;
 }
 - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
 }

 - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
 }
 -(void)initWithdonghua:(NSString *)name andcount:(int)cuont
 {
if (self.tom.isAnimating) {
    return;
}
NSMutableArray *arrM=[NSMutableArray array];
for (int i=0; i<cuont; i++) {
    //全路径没有缓存,自动释放
    NSString *filename=[NSString stringWithFormat:@"%@_%02d.jpg",name,i];
    NSString *path=[[NSBundle mainBundle]pathForResource:filename ofType:nil];
    UIImage *image=[UIImage imageWithContentsOfFile:path];
    [arrM addObject:image];
}
self.tom.animationImages=arrM;
self.tom.animationRepeatCount=1;
//播放时间长度
self.tom.animationDuration=arrM.count*0.1;
[self.tom startAnimating];
//类似于定时器,多长时间后执行某个方法
CGFloat delay=self.tom.animationDuration;
[self performSelector:@selector(clearCache) withObject:nil afterDelay:delay];
 }
 -(void)clearCache
 {
self.tom.animationImages=nil;
 }
 - (IBAction)eat
 {
[self initWithdonghua:@"eat" andcount:40];
 }
 - (IBAction)fart
 {
[self initWithdonghua:@"fart" andcount:28];
 }
 - (IBAction)drink
 {
[self initWithdonghua:@"drink" andcount:81];
 }
 - (IBAction)scratch
 {
[self initWithdonghua:@"scratch" andcount:56];
 }
 - (IBAction)pie
 {
[self initWithdonghua:@"pie" andcount:24];
 }
 - (IBAction)cymbal
 {
[self initWithdonghua:@"cymbal" andcount:13];
 }
 - (IBAction)knock
 {
[self initWithdonghua:@"knockout" andcount:81];
 }
 - (IBAction)left
 {
[self initWithdonghua:@"footLeft" andcount:30];
 }
 - (IBAction)right
 {
[self initWithdonghua:@"footRight" andcount:30];
 }
 - (IBAction)Angry
 {
[self initWithdonghua:@"angry" andcount:26];
 }
 - (IBAction)Stomach
 {
[self initWithdonghua:@"stomach" andcount:34];
 }
 @end
屏幕快照 2016-03-05 05.59.04 PM.png 屏幕快照 2016-03-05 06.04.59 PM.png 屏幕快照 2016-03-05 06.05.53 PM.png

相关文章

  • Tom-猫

  • Tom-留言条

    Dear Tom, I'm in New York! (Part A Intention) Unfortunate...

  • 猫说:曾经的拥有,都是因为现在的不珍惜!

    天猫培训天猫培训天猫培训天猫培训天猫培训天猫培训天猫培训天猫培训天猫培训天猫培训天猫培训天猫培训天猫培训天猫培训天...

  • 文章不再同步这里,请关注微信公众号【Python猫】

    Python猫Python猫Python猫 Python猫 Python猫 Python猫

  • 猫。

    猫的品种有很多。如:英国短毛猫,折耳猫,布偶猫,暹罗猫,美国短毛猫,波斯猫,异国短毛猫,挪威森林猫,孟买猫,缅因猫...

  • 猫!猫!猫!

    猫,世界上最美好的生物之一 大家还记得那个 立志画一百只猫的插画师吗? 不记得的看这里 前情提要,点击下方图片 ↓...

  • 赛级猫

    平生爱猫,说不出原因,就是由衷地喜欢猫。猫的性格、猫的声音、猫的情感、猫的皮毛、猫的爪子、猫的瞳孔、猫的耳朵...

  • 2018.2.3没有买卖就没有杀害

    不要囤猫,不要囤猫,不要囤猫! 不要吸猫,不要吸猫,不要吸猫!

  • 养猫

    养猫细则: 1,猫粮。(猫粮,猫罐头,零食。猫喝水的盆。) 2,猫厕所。(猫厕所,猫砂,最好吸味的) 3,猫窝。(...

  • 很多人养过猫,但不知道猫的习性等等。 猫有许多品种:波斯猫、狸花猫、黄毛猫、狮子猫、云猫、豹猫、简州猫、玄猫等等。...

网友评论

    本文标题:Tom-猫

    本文链接:https://www.haomeiwen.com/subject/mbxakttx.html