- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
// 摸脸
_imageview=[[UIImageView alloc]initWithFrame:self.view.frame];
_imageview.image=[UIImage imageNamed:@"angry_00.jpg"];
_imageview.userInteractionEnabled=YES;
[self.view addSubview:_imageview];
UIButton *button =[UIButton buttonWithType:UIButtonTypeSystem];
button.frame=CGRectMake(100, 170, 180, 150);
[button addTarget:self action:@selector(perss:) forControlEvents:UIControlEventTouchUpInside];
[_imageview addSubview:button];
// foot left
// _imageview.image=[UIImage imageNamed:@"footLeft_00.jpg"];
// _imageview.userInteractionEnabled=YES;
UIButton *button1=[UIButton buttonWithType:UIButtonTypeSystem];
button1.frame=CGRectMake(185, 600, 50, 50);
// button1.backgroundColor=[UIColor greenColor];
// [_imageview addSubview:button1];
[button1 addTarget:self action:@selector(footleft:) forControlEvents:UIControlEventTouchUpInside];
[_imageview addSubview:button1];
// foot right
UIButton *button2=[UIButton buttonWithType:UIButtonTypeSystem];
button2.frame=CGRectMake(130, 600, 50, 50);
// button2.backgroundColor=[UIColor greenColor];
[button2 addTarget:self action:@selector(footringht:) forControlEvents:UIControlEventTouchUpInside];
[_imageview addSubview:button2];
// stomach
UIButton *button3=[UIButton buttonWithType:UIButtonTypeSystem];
button3.frame=CGRectMake(120, 430, 130, 150);
// button3.backgroundColor=[UIColor greenColor];
[button3 addTarget:self action:@selector(stomach:) forControlEvents:UIControlEventTouchUpInside];
[_imageview addSubview:button3];
// drink
UIImageView *image1=[[UIImageView alloc]initWithFrame:CGRectMake(10, 400, 50, 50)];
image1.image=[UIImage imageNamed:@"drink"];
[_imageview addSubview:image1];
UIButton *button4=[UIButton buttonWithType:UIButtonTypeSystem];
button4.frame=CGRectMake(10, 400, 50, 50);
// button4.backgroundColor=[UIColor greenColor];
[_imageview addSubview:button4];
[button4 addTarget:self action:@selector(drink:) forControlEvents:UIControlEventTouchUpInside];
// cymbal
UIImageView *image2=[[UIImageView alloc]initWithFrame:CGRectMake(10, 450, 50, 50)];
image2.image=[UIImage imageNamed:@"cymbal"];
[_imageview addSubview:image2];
UIButton *button5=[UIButton buttonWithType:UIButtonTypeSystem];
button5.frame=CGRectMake(10, 450, 50, 50);
// button5.backgroundColor=[UIColor greenColor];
[_imageview addSubview:button5];
[button5 addTarget:self action:@selector(cymbal:) forControlEvents:UIControlEventTouchUpInside];
// scratch 挠屏
UIImageView *image3=[[UIImageView alloc]initWithFrame:CGRectMake(10, 500, 50, 50)];
image3.image=[UIImage imageNamed:@"scratch"];
[_imageview addSubview:image3];
UIButton *button6=[[UIButton alloc]initWithFrame:CGRectMake(10, 500, 50, 50)];
// button6.backgroundColor=[UIColor greenColor];
[_imageview addSubview:button6];
[button6 addTarget:self action:@selector(scratch:) forControlEvents:UIControlEventTouchUpInside];
// pie
UIImageView *image4=[[UIImageView alloc]initWithFrame:CGRectMake(10, 550, 50, 50)];
image4.image=[UIImage imageNamed:@"pie"];
[_imageview addSubview:image4];
UIButton *button7=[UIButton buttonWithType:UIButtonTypeSystem];
button7.frame=CGRectMake(10, 550, 50, 50);
[button7 addTarget:self action:@selector(pie:) forControlEvents:UIControlEventTouchUpInside];
[_imageview addSubview:button7];
UIImageView *image5=[[UIImageView alloc]initWithFrame:CGRectMake(310, 400, 50, 50)];
image5.image=[UIImage imageNamed:@"eat"];
[_imageview addSubview:image5];
UIButton *button8=[UIButton buttonWithType:UIButtonTypeSystem];
button8.frame=CGRectMake(310, 400, 50, 50);
[_imageview addSubview:button7];
[button7 addTarget:self action:@selector(eat:) forControlEvents:UIControlEventTouchUpInside];
UIImageView *image6=[[UIImageView alloc]initWithFrame:CGRectMake(310, 450, 50, 50)];
image6.image=[UIImage imageNamed:@"fart"];
[_imageview addSubview:image6];
UIButton *button9=[UIButton buttonWithType:UIButtonTypeSystem];
button9.frame=CGRectMake(310, 450, 50, 50) ;
[_imageview addSubview:button9];
[button9 addTarget:self action:@selector(fart:) forControlEvents:UIControlEventTouchUpInside];
}
// 摸脸
-(void)perss:(UIButton *)button{
self.imgArr=[NSMutableArray array];
for (NSInteger i = 6; i<80; i++) {
NSString *str=[NSString stringWithFormat:@"knockout_%02ld.jpg",i];
[self.imgArr addObject:[UIImage imageNamed:str]];
}
self.imageview.animationImages = self.imgArr;
self.imageview.animationDuration=2;
self.imageview.animationRepeatCount=5;
[_imageview startAnimating];
}
// foot left
-(void)footleft:(UIButton *)button{
NSMutableArray *arr =[NSMutableArray array];
for (NSInteger i = 0; i<30; i++) {
NSString *str=[NSString stringWithFormat:@"footLeft_%02ld.jpg",i];
[arr addObject:[UIImage imageNamed:str]];
}
self.imageview.animationImages=arr;
self.imageview.animationDuration=1;
self.imageview.animationRepeatCount=1;
[self.imageview startAnimating];
}
// foot right
-(void)footringht:(UIButton *)button{
NSMutableArray *arr =[NSMutableArray array];
for (NSInteger i = 0; i<30; i++) {
NSString *str=[NSString stringWithFormat:@"footRight_%02ld.jpg",i];
[arr addObject:[UIImage imageNamed:str]];
}
self.imageview.animationImages=arr;
self.imageview.animationDuration=1;
self.imageview.animationRepeatCount=1;
[self.imageview startAnimating];
}
//stomach
-(void)stomach:(UIButton *)button{
NSMutableArray *arr =[NSMutableArray array];
for (NSInteger i = 0; i<34; i++) {
NSString *str=[NSString stringWithFormat:@"Stomach_%02ld.jpg",i];
[arr addObject:[UIImage imageNamed:str]];
}
self.imageview.animationImages=arr;
self.imageview.animationDuration=1;
self.imageview.animationRepeatCount=3;
[self.imageview startAnimating];
}
//drink
-(void)drink:(UIButton *)button{
NSMutableArray *arr=[NSMutableArray array];
for (NSInteger i =0; i<81; i++) {
NSString *str=[NSString stringWithFormat:@"drink_%02ld.jpg",i];
[arr addObject:[UIImage imageNamed:str]];
}
_imageview.animationRepeatCount=3;
_imageview.animationImages=arr;
_imageview.animationDuration=5;
[_imageview startAnimating];
}
-(void)cymbal:(UIButton *)button{
NSMutableArray *arr=[NSMutableArray array];
for (NSInteger i =0; i<13; i++) {
NSString *str=[NSString stringWithFormat:@"Cymbal_%02ld.jpg",i];
[arr addObject:[UIImage imageNamed:str]];
}
_imageview.animationImages=arr;
_imageview.animationDuration=1;
_imageview.animationRepeatCount=3;
[_imageview startAnimating];
}
// scratch
-(void)scratch:(UIButton *)button{
NSMutableArray *arr=[NSMutableArray array];
for (NSInteger i =0; i<56; i++) {
NSString *str=[NSString stringWithFormat:@"scratch_%02ld.jpg",i];
[arr addObject:[UIImage imageNamed:str]];
}
_imageview.animationImages=arr;
_imageview.animationDuration=5;
_imageview.animationRepeatCount=5;
[_imageview startAnimating];
}
// pie
-(void)pie:(UIButton *)button{
NSMutableArray *arr=[NSMutableArray array];
for (NSInteger i =0; i<24; i++) {
NSString *str=[NSString stringWithFormat:@"pie_%02ld.jpg",i];
[arr addObject:[UIImage imageNamed:str]];
}
_imageview.animationImages=arr;
_imageview.animationDuration=5;
_imageview.animationRepeatCount=5;
[_imageview startAnimating];
}
//eat
-(void)eat:(UIButton *)button{
NSMutableArray *arr=[NSMutableArray array];
for (NSInteger i =0; i<40; i++) {
NSString *str=[NSString stringWithFormat:@"eat_%02ld.jpg",i];
[arr addObject:[UIImage imageNamed:str]];
}
_imageview.animationImages=arr;
_imageview.animationDuration=2;
_imageview.animationRepeatCount=5;
[_imageview startAnimating];
}
-(void)fart:(UIButton*)button{
NSMutableArray *arr=[NSMutableArray array];
for (NSInteger i =0; i<28; i++) {
NSString *str=[NSString stringWithFormat:@"fart_%02ld.jpg",i];
[arr addObject:[UIImage imageNamed:str]];
}
_imageview.animationImages=arr;
_imageview.animationDuration=2;
_imageview.animationRepeatCount=5;
[_imageview startAnimating];
}