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中刪除它們?爲什麼動畫總是從左上角開始,即使我正在使用隨機?