3

次の画像を参照してください。

ここに画像の説明を入力

. . . . 適切な点で終わらないことに注意してください。

次の描画コードを使用します。

CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 2.0);
CGContextSetStrokeColorWithColor(context, [UIColor whiteColor].CGColor);

CGContextMoveToPoint(context, self.width - 20, (self.height / 2) - 5);
CGContextAddLineToPoint(context, self.width - 12, self.height / 2);
CGContextStrokePath(context);

CGContextMoveToPoint(context, self.width - 20, (self.height / 2) + 5);
CGContextAddLineToPoint(context, self.width - 12, self.height / 2);
CGContextStrokePath(context);

線が点で終わるべきだと言う簡単な方法はありますか? 座標を少し変更することでこれを修正できることはわかっていますが、もっと知りたいと思っています。

4

1 に答える 1

2

線が結合されていないため、CGLineJoinスタイルは有効になりません。次のコードで問題ないはずです。

CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 2.0);
CGContextSetStrokeColorWithColor(context, [UIColor whiteColor].CGColor);

CGContextMoveToPoint(context, self.width - 20, (self.height / 2) - 5);
CGContextAddLineToPoint(context, self.width - 12, self.height / 2);
CGContextAddLineToPoint(context, self.width - 20, self.height / 2 + 5);
CGContextStrokePath(context);
于 2013-08-30T05:56:57.007 に答える