我在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 2013-03-12 10:33:54
你能給個答案嗎?我不太瞭解。謝謝! – 2013-03-12 10:35:20
讓我猜測?你沒有變形,只是一條線?每次觸摸移動時,都會關閉當前的子路徑。 – Abizern 2013-03-12 10:45:11