touchesMovedにUIBezierPathで図形を描画します。UIBezierPathの中の色を塗りつぶす方法は?
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
secondPoint = firstPoint;
firstPoint = [touch previousLocationInView:self];
currentPoint = [touch locationInView:self];
CGPoint mid1 = midPoint(firstPoint, secondPoint);
CGPoint mid2 = midPoint(currentPoint, firstPoint);
[bezierPath moveToPoint:mid1];
[bezierPath addQuadCurveToPoint:mid2 controlPoint:firstPoint];
[self setNeedsDisplay];
}
closePathの後にRED色を塗りたいができない。助けてください!
- (void)drawRect:(CGRect)rect
{
UIColor *fillColor = [UIColor redColor];
[fillColor setFill];
UIColor *strokeColor = [UIColor blueColor];
[strokeColor setStroke];
[bezierPath closePath];
[bezierPath fill];
[bezierPath stroke];
}
実際にパスを撫でているようには見えないので、閉じることはありません。 – Abizern
あなたは答えをくれませんか?それほど分かりません。ありがとう! –
私は推測させてください?あなたは形をしていない、ただの線ですか?タッチが動くたびに、現在のサブパスが閉じます。 – Abizern