-1
화면을 누르면 uiimageview를 만들고보고 싶습니다. 나는 손가락을 들어 올리기 전에 uiimageview를 화면 주위로 움직이고 손가락을 뗄 때만 이미지를 설정하려고합니다. Heres는 내가 무슨 짓을했는지 :UITapGestureRecognizer 및 UIPanGestureRecognizer
- (IBAction)tap:(UITapGestureRecognizer *)recognizer {
CGPoint location = [recognizer locationInView:self.view];
UIImageView *circle = [[UIImageView alloc] initWithFrame:CGRectMake(location.x, location.y, 50, 50)];
circle.userInteractionEnabled = YES;
[circle setImage:[UIImage imageNamed:@"monkey_1.png"]];
[self.view addSubview:circle];
UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:circle action:nil];
[recognizer requireGestureRecognizerToFail:pan];
CGPoint translation = [pan translationInView:circle];
pan.view.center = CGPointMake(pan.view.center.x + translation.x, pan.view.center.y + translation.y);
[pan setTranslation:CGPointMake(0, 0) inView:self.view];
}
이렇게하면 단일 제스처로하는 것이 더 쉬울 것입니다. 길게 누르는 제스처를 만들고 그 행동에 상태를 감지하십시오. 시작하면 이미지를 보여줄 것이고, 변경하면 이미지를 옮길 것이고, 끝 부분을 정리할 것입니다. – farski