원점에서 얼마나 멀리 떨어져 있는지에 따라 자동으로 크기가 조정되는 손가락으로 직선을 그려야합니다.스트레치 UIBezierPath 라인?
중간에 화면을 터치하고 손가락을 밀어 내면 화면에서 손가락이 움직이면서 선이 '늘어나고'피벗 (orgin) 지점을 중심으로 선회합니다. 내가 손가락을 들어 올렸을 때. Destination Point는 완성되어 라인을 만들어야합니다. 화면에서 손가락을 드래그하여 화면에 '그리기'할 수는 있지만 원하는 것은 아닙니다.
UIBeizerPath moveToPoint 도움이 될 것이라고 생각하지만 그냥 물건을 망칠.
내가 뭘 잘못하고 있니?
- (id)initWithFrame:(CGRect)frame
{
//default line properties
myPath=[[UIBezierPath alloc]init];
myPath.lineCapStyle=kCGLineCapRound;
myPath.miterLimit=0;
myPath.lineWidth=lineWidth;
brushPattern=[UIColor blackColor];
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
CGPoint curPoint = [[touches anyObject] locationInView:self];
lastPoint = curPoint;
[myPath moveToPoint:lastPoint];
[pathArray addObject:myPath];
[self setNeedsDisplay];
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
CGPoint curPoint = [[touches anyObject] locationInView:self];
myPath.lineWidth=lineWidth;
brushPattern=[UIColor redColor]; //red to show it hasn't been added yet.
[myPath moveToPoint:tempPoint];
[self setNeedsDisplay];
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
CGPoint curPoint = [[touches anyObject] locationInView:self];
myPath.lineWidth=lineWidth;
brushPattern=[UIColor blackColor]; //finalize the line with black color
[myPath addLineToPoint:curPoint];
[self setNeedsDisplay];
}
고마워요. 배열에 저장하고 다시 그립니다. 미래에 나올 수있는 기회가 언제 생길까요? – JasonBourne
나는 어떤 이슈도 상상할 수 없다. 거기에별로 없습니다! 그러나 당신은 기본적인 문제를 가지고 있습니다. 그래서 미래의 다른 구현을 추구해야한다면, 당신은 잘 무장하고 있습니다. – Rob
귀하의 모든 도움에 감사드립니다! 그것은 나를 미치게했다! – JasonBourne