我正在尝试为 UIButton 设置动画。但是在它的动画过程中,没有与 UIButton 的交互。预期的行为是能够在按钮移动时单击它。这是 UIButton 和动画的代码片段:
UIImage *cloudImage = [UIImage imageNamed:@"sprite.png"];
UIButton moveBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[moveBtn setFrame:CGRectMake(0.0, 80.0, cloudImage.size.width, cloudImage.size.height)];
[moveBtn setImage:cloudImage forState:UIControlStateNormal];
[moveBtn addTarget:self action:@selector(hit:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:moveBtn];
CGPoint newLeftCenter = CGPointMake( 300.0f + moveBtn.frame.size.width / 2.0f, moveBtn.center.y);
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:5.0f];
[UIView setAnimationRepeatCount:HUGE_VALF];
moveBtn.center = newLeftCenter;
[UIView commitAnimations];
hit
选择器只显示一个 NSLog 来显示按钮是否响应它。任何帮助,将不胜感激。