Drawing a polygon with one color for stroke, and a different one for fill?

前端 未结 3 464
鱼传尺愫
鱼传尺愫 2020-12-09 13:28

I\'m having trouble with drawing some lines that are stroked with a color and then filling their insides (they make a polygon) with another one.

UIColor *hou         


        
3条回答
  •  眼角桃花
    2020-12-09 13:43

    You can use

    CGContextDrawPath(context, kCGPathFillStroke);
    

    instead of

    CGContextFillPath(context);
    CGContextStrokePath(context);
    

    The problem is that both CGContextFillPath() and CGContextStrokePath(context) clear the current path, so that only the first operation succeeds, and the second operation draws nothing. CGContextDrawPath() combines fill and stroke without clearing the path in between.

提交回复
热议问题