1
我怎樣才能讓圖像在被觸摸時消失。可可觸摸 - 在UIImageView中觸摸
這是我的代碼來創建圖像。它隨機顯示在屏幕上,因此在您觸摸它後,它會消失,並在新位置出現新圖像。
-(void)drawStarsAndDetectTouches{ //uses random numbers to display a star on screen
//create random position
int xCoordinate = arc4random() % 267;
int yCoordinate = arc4random() % 420;
//make sure it doesnt draw onto titiles
if (yCoordinate <= 40) {
yCoordinate = arc4random() % 420;
}
UIImageView *starImgView = [[UIImageView alloc] initWithFrame:CGRectMake(xCoordinate, yCoordinate, 58, 40)]; //create ImageView
starImgView.image = [UIImage imageNamed:@"star.png"];
[self.view addSubview: starImgView];
[starImgView release];
}
(似乎更容易),我可以編輯我的上面的代碼是一個按鈕?因爲它需要全部編程完成 – user377419 2010-07-24 15:16:09
是的,這應該工作。我認爲你可以做一些類似於我剛剛編輯的答案。 – Benjamin 2010-07-24 18:02:27