0
私はコアグラフィックを使用して2つの長方形のパスを作成しようとしています。色を使ってパスを塗り潰そうとすると、オーバーラップした色が塗りつぶされません。CoreGraphics - 色が塗りつぶされていない重複したパスエリア
が出力
私は緑色が全て閉じた領域を充填する必要
- (void)drawRect:(CGRect)rect {
CGPoint topLeft = CGPointMake(121, 116);
CGPoint topRight = CGPointMake(221, 216);
CGPoint middleLeft = CGPointMake(121, 180);
CGPoint middleRight = CGPointMake(221, 280);
CGPoint bottomLeft = CGPointMake(250, 56);
CGPoint bottomRight = CGPointMake(350, 156);
CGMutablePathRef subpath1 = CGPathCreateMutable();
CGPathMoveToPoint(subpath1, NULL, topLeft.x, topLeft.y);
CGPathAddLineToPoint(subpath1, NULL, topRight.x, topRight.y);
CGPathAddLineToPoint(subpath1, NULL, middleRight.x, middleRight.y);
CGPathAddLineToPoint(subpath1, NULL, middleLeft.x, middleLeft.y);
CGPathAddLineToPoint(subpath1, NULL, topLeft.x, topLeft.y);
CGPathCloseSubpath(subpath1);
CGMutablePathRef subpath2 = CGPathCreateMutable();
CGPathMoveToPoint(subpath2, NULL, middleLeft.x, middleLeft.y);
CGPathAddLineToPoint(subpath2, NULL, middleRight.x, middleRight.y);
CGPathAddLineToPoint(subpath2, NULL, bottomRight.x, bottomRight.y);
CGPathAddLineToPoint(subpath2, NULL, bottomLeft.x, bottomLeft.y);
CGPathAddLineToPoint(subpath2, NULL, middleLeft.x, middleLeft.y);
CGPathCloseSubpath(subpath2);
CGMutablePathRef path = CGPathCreateMutable();
CGPathAddPath(path, NULL, subpath1);
CGPathAddPath(path, NULL, subpath2);
CGPathCloseSubpath(path);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [UIColor colorWithRed:0.19 green:0.42 blue:0.09 alpha:1.0].CGColor);
CGContextSetStrokeColorWithColor(context, [UIColor colorWithRed:0.19 green:0.42 blue:0.09 alpha:1.0].CGColor);
CGContextSetBlendMode(context, kCGBlendModeMultiply);
CGContextSetAlpha(context, 1.0);
CGContextAddPath(context, path);
CGContextDrawPath(context, kCGPathFillStroke);
}
で使用されるコードです。この問題を解決する方法を教えてください。