Я рисую фигуру с помощью UIBezierPath в touchesMoved.
-(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, но не могу. Пожалуйста помоги!
- (void)drawRect:(CGRect)rect
{
UIColor *fillColor = [UIColor redColor];
[fillColor setFill];
UIColor *strokeColor = [UIColor blueColor];
[strokeColor setStroke];
[bezierPath closePath];
[bezierPath fill];
[bezierPath stroke];
}
setFill
фактически не устанавливает контекст заполнения, как вы ожидаете (см. это: stackoverflow.com/questions/10623545/). Вместо этого установите заливку с эквивалентом obj-Clet context = UIGraphicsGetCurrentContext()!; context.setFillColor(UIColor.blue.cgColor)
- person pseudosudo   schedule 13.11.2018