我在控制器中添加了一个 UIView,然后在该视图上添加了一个 UIButton。我正在水平动画那个视图,所以随着那个视图我的按钮也在移动,因为它添加到那个视图上,但是我希望当用户触摸按钮(这是动画)按钮应该动画起来并立即下降。应该执行此按钮的动画,而旧的视图动画(按钮的超级视图)正在动画。
我已经这样做了,但是,按钮正在向上 n 动画,直到该视图的大动画没有开始,一旦按钮的超级视图的动画开始,它就不会执行它之前执行的动画(触摸时)。
这是代码
tempRabbit = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 360, 360)];
tempView=[[UIView alloc]initWithFrame:CGRectMake(900, 0, 1024, 500)];
UIImageView *temp=[[UIImageView alloc]initWithFrame:CGRectMake(0, 200, 360, 360)];
UIButton *tempBtn=[UIButton buttonWithType:UIButtonTypeRoundedRect];
[tempBtn setFrame:CGRectMake(0, 0, 360, 360)];
[tempBtn addTarget:self action:@selector(rabbitTaped1) forControlEvents:UIControlEventTouchUpInside];
[tempBtn setTitle:@"Show View" forState:UIControlStateNormal];
NSArray *animationArray=[[NSArray alloc]init];
animationArray=[NSArray arrayWithObjects:
[UIImage imageNamed:@"rabbit1.png"],
[UIImage imageNamed:@"rabbit2.png"],
[UIImage imageNamed:@"rabbit3.png"],
[UIImage imageNamed:@"rabbit4.png"],
[UIImage imageNamed:@"rabbit5.png"],
[UIImage imageNamed:@"rabbit6.png"],
[UIImage imageNamed:@"rabbit7.png"],
[UIImage imageNamed:@"rabbit8.png"],
[UIImage imageNamed:@"rabbit9.png"],
[UIImage imageNamed:@"rabbit10.png"],
[UIImage imageNamed:@"rabbit11.png"],
[UIImage imageNamed:@"rabbit12.png"],
[UIImage imageNamed:@"rabbit13.png"], nil];
temp.animationImages=animationArray;
temp.animationDuration=2;
temp.animationRepeatCount=0;
[temp startAnimating];
//[tempRabbit addSubview:temp];
[tempRabbit addSubview:tempBtn];
[tempView addSubview:tempRabbit];
[self.view addSubview:tempView];