我用下面的代码为填充路径viewDidLoad
它的作品完美CGContextFillPath(上下文)创建一个行
UIGraphicsBeginImageContext(_drawingPad.frame.size);
CGContextRef context1 = UIGraphicsGetCurrentContext();
CGContextMoveToPoint(context1, 300, 300);
CGContextAddLineToPoint(context1, 400, 350);
CGContextAddLineToPoint(context1, 300, 400);
CGContextAddLineToPoint(context1, 250, 350);
CGContextAddLineToPoint(context1, 300, 300);
CGContextClosePath(context1);
//CGContextStrokePath(context1);
CGContextSetFillColorWithColor(context1, [UIColor redColor].CGColor);
CGContextFillPath(context1);
CGContextStrokePath(context1);
也是我创建一个线的时候开始接触.. 但将填充路径时被删除在创建线条之前擦除。
OP * *在当前图形上下文中创建路径。您的代码首先创建一个单独的CGMutablePathRef,然后将其添加到当前上下文中。这当然也是有效的,但是(正如我所假设的)独立于OP的问题。我当然可能是错的:-) –