UI基础第一章3编写汤姆猫

本人小菜一个,正在学习iOS,有兴趣盆友可以加我好友,暂且不提供视频,需要的留言(大神勿喷)!//

//ViewController.m

//汤姆猫第一次


这个只是实现了几个步骤,且这是没有进行优化的,后续在更新中····


UI基础第一章3编写汤姆猫_第1张图片

//

//

#import"ViewController.h"

@interfaceViewController()

- (IBAction)drinkBtn;

@property(weak,nonatomic)IBOutletUIImageView*picture;

- (IBAction)headBtn;

- (IBAction)rightBtn;

@end

@implementationViewController

- (IBAction)drinkBtn

{

if(self.picture.isAnimating)

{

return;

}

NSMutableArray*muta = [NSMutableArrayarray];//数组创建

for(inti =0; i <81; i++)//循环遍历数组提取去每一帧动画

{

NSString*str = [NSStringstringWithFormat:@"drink_%02d",i];//提取

UIImage*iamge = [UIImageimageNamed:str];//这是创建对象,以便引入数组

[mutaaddObject:iamge];//引入数组

}

self.picture.animationImages= muta;//提取数组中的动画

self.picture.animationDuration=0.05*81;//动画播放速度

self.picture.animationRepeatCount=1;

[self.picturestartAnimating];

}

- (IBAction)headBtn//头部

{

if(self.picture.isAnimating)

{

return;

}

NSMutableArray*muta = [NSMutableArrayarray];

for(inti =0; i <81; i++)

{

NSString*str = [NSStringstringWithFormat:@"knockout_%02d",i];

UIImage*iamge = [UIImageimageNamed:str];

[mutaaddObject:iamge];

}

self.picture.animationImages= muta;

self.picture.animationDuration=0.05*81;

self.picture.animationRepeatCount=1;

[self.picturestartAnimating];

}

- (IBAction)rightBtn//脚

{

if(self.picture.isAnimating)

{

return;

}

NSMutableArray*muta = [NSMutableArrayarray];

for(inti =0; i <30; i++)

{

NSString*str = [NSStringstringWithFormat:@"footLeft_%02d",i];

UIImage*image = [UIImageimageNamed:str];

[mutaaddObject:image];

}

self.picture.animationImages= muta;

self.picture.animationDuration=0.05*30;

self.picture.animationRepeatCount=1;

[self.picturestartAnimating];

}

@end

你可能感兴趣的:(UI基础第一章3编写汤姆猫)