2012-03-30 20 views
6

UIViewに塗りつぶした(!)半円を描く最もよい方法は何ですか?私はCGContextAddArc関数を使って遊んだが、それは充填を提供していないようだ。ここに私が描きたいのは、2つの塗りつぶした半円です。塗りつぶされた半円を描く

enter image description here

答えて

15
CGContextBeginPath(gc); 
CGContextAddArc(gc, 100, 100, 50, -M_PI_2, M_PI_2, 1); 
CGContextClosePath(gc); // could be omitted 
CGContextSetFillColorWithColor(gc, [UIColor cyanColor].CGColor); 
CGContextFillPath(gc); 
+0

私の代わりに "CGContextSetFillColor" の "CGContextSetFillColorWithColor" 機能を使用する必要がありました。それでそれは素晴らしい作品です。ありがとう! – Bernd

+0

一定。どういたしまして。 –

+0

これを実行するにはCGContextRef gc = UIGraphicsGetCurrentContext();を使用してcgを定義します。 – josef

関連する問題