0
我正在使用此代码在屏幕上显示随机图像。Xcode删除触摸事件图像?
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
UIImageView *cloud = [[UIImageView alloc]
initWithImage:[UIImage imageNamed:@"spit.png"]];
cloud.center = CGPointMake(random() % 250, random() % 400); //Random place
[cloud setAlpha:1];
[self.view addSubview:cloud];
[cloud release];
cloud.frame = CGRectMake(0, 0, 300, 300);
[UIView beginAnimations: @"cloddy" context: nil];
[UIView setAnimationDuration: 0.5f];
[UIView setAnimationCurve: UIViewAnimationCurveEaseIn];
// Size when done
cloud.frame = CGRectMake(0, 0, 75, 75);
cloud.center = location;
[UIView commitAnimations];
}
经过几次触摸屏幕变得满满。我如何在另一个IBAction中删除它们?为什么动画总是从左上角开始,即使我正在使用随机?