터치했을 때 이미지가 사라질 수 있도록 어떻게 만들 수 있습니까?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
그래, 작동해야합니다. 내 대답에 내가 편집 한 것과 같은 것을 할 수 있다고 생각합니다. – Benjamin