中央から三角形が切り取られた半透明の黒い長方形を描画しようとしています。
これは、以下のコードで完全に機能します。しかし、三角形の角を丸くしたいのです。
ストロークに CGContextSetLineCap を設定したり、クオーツでパスを作成して CGContextAddArcToPoint を使用したりするなど、丸みを帯びた角を追加するためのさまざまな手法をいくつか試しましたが、うまくいきませんでした。
前述したように、以下のコードは三角形のカットアウトで機能します。三角形の角を丸くする方法を教えてください。
CGContextRef context = UIGraphicsGetCurrentContext();
CGPoint position = CGPointMake(rect.size.width/2, rect.size.height * .7);
CGSize size = CGSizeMake(rect.size.width*.8, rect.size.height*.5);
CGFloat firstPointX = (position.x - (size.width / 2));
CGFloat firstPointY = (position.y - (size.height));
CGPoint firstPoint = CGPointMake(firstPointX, firstPointY);
CGFloat secondPointX = position.x + (size.width / 2);
CGFloat secondPointY = position.y - (size.height);
CGPoint secondPoint = CGPointMake(secondPointX, secondPointY);
UIBezierPath *path = [UIBezierPath bezierPath];
[path moveToPoint:position];
[path addLineToPoint:firstPoint];
[path moveToPoint:firstPoint];
[path addLineToPoint:secondPoint];
[path addLineToPoint:position];
[path closePath];
CGContextAddRect(context, rect);
CGContextAddPath(context, path.CGPath);
CGContextEOClip(context);
UIColor *translucentColor = [UIColor colorWithWhite:0 alpha:0.5];
CGContextSetFillColorWithColor(context, translucentColor.CGColor);
CGContextFillRect(context, rect);
UIGraphicsEndImageContext();
編集:これは私が達成しようとしていることの例です。