저는 Objective C에서 2 주 동안 프로그래밍을 해왔고, 제가하고있는 약간의 연습 iPhone 응용 프로그램의 기능은 이미지 위에 선을 그리는 것입니다. 내보기 컨트롤러의 viewDidLoadMethod에서 나는 나 이미지에 내 손가락을 이동할 때 코드가 실행UIImageView에 사용자 정의 경로 그리기
UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc]
initWithTarget:self action:@selector(drawLine:)];
[panGestureRecognizer setMinimumNumberOfTouches:1];
[panGestureRecognizer setMaximumNumberOfTouches:1];
[self.imageView addGestureRecognizer:panGestureRecognizer];
panGestureRecognizer = nil;
와 panGestureRecognizer에 응답 기능을 UIPanGestureRecognizer을
- (void)drawLine:(UIPanGestureRecognizer *)panGestureRecognizer {
CGPoint start = [panGestureRecognizer locationInView:self.imageView];
CGPoint shift = [panGestureRecognizer translationInView:self.imageView];
CGPoint final;
final.x = start.x + shift.x;
final.y = start.y + shift.y;
UIBezierPath *path = [[UIBezierPath alloc] init];
[path moveToPoint:start];
[path addLineToPoint:final];
[path strokeWithBlendMode:kCGBlendModeNormal alpha:1.0];
}
되어 초기화되지만 선이 표시되지 않습니다. 이것이 이미 imageView에있는 이미지의 뒤에 있는지, 아니면 전혀 그려지지 않은 것인지 확실하지 않습니다. 이 문제에 접근하는 방법에 대한 도움을 주시면 감사하겠습니다. 올바른 방향인지 잘 모르겠습니다. 감사.
대단히 감사합니다 당신의 대답 모두. – mcfisty