2012-04-24 3 views
2

私はiOS上で丸い四角形を描いています。CGContextStrokeRectWithWidth内部の丸め?

この矩形は、ベジェパスでクリッピングしている画像の背景があり、その内部に2ピクセルの幅のストロークを描画しています。

私の問題は、一見丸い矩形のパスに従うのではなく、内側に鋭いエッジがあることです。

私が扱っている問題を表示するために白い色を増やしたスクリーンショットです。

enter image description here

ここに私のコードです:私はあなたがする必要があるとしているものだと思い

CGContextRef context = UIGraphicsGetCurrentContext(); 
CGPathRef strokeRect = [UIBezierPath bezierPathWithRoundedRect:rect cornerRadius:2].CGPath; 
CGContextAddPath(context, strokeRect); 
CGContextClip(context); 

// draw background 
[[UIImage imageNamed:@"background.png"] drawInRect:rect]; 

// draw stroke 
CGContextSetRGBStrokeColor(context, 1.0, 1.0, 1.0, 0.1); 
CGContextStrokeRectWithWidth(context, rect, 2); 

答えて

0

は、角の丸みを内側にコンテキストをクリップして、10%白でコンテキストを満たしています。