0
A
答えて
3
4
あなたはdrawRect:
メソッドをオーバーライドするクラスを実装し、パイを自分で描画する必要があります。あなたは、特に円の一部を描画するaddArcWithCenter:radius:startAngle:endAngle:clockwise:方法に見て、UIBezierPathクラスを使用すると思います。
もthis articleとthis articleを参照してください。
1
これは、他の誰かのコードのように見える場合、私はウェブサイトでそれを行う方法を働いていたので、それはだと警告し、私は長くないiPhoneを起動した後にこれをした追加の警告と役に立つかもしれません。どのビットが非効率的か間違っているかを教えてくれる人は歓迎します、私はまだ学んでいます。
static inline float radians(double degrees) { return degrees * M_PI/180; }
// making a simple pac man shape
- (UIImage*)getImage {
UIImage* image;
if(self.completion == 100.0f) {
image = [UIImage imageNamed:@"completedTaskIcon.png"];
} else {
UIGraphicsBeginImageContext(CGSizeMake(SIDELENGTH, SIDELENGTH));
CGContextRef context = UIGraphicsGetCurrentContext();
// the image should have a clear background
[[UIColor clearColor] set];
CGRect myRect = CGRectMake(0.0f, 0.0f, SIDELENGTH, SIDELENGTH);
UIRectFill(myRect);
// color was hopefully set before this method called
[self.color set];
// centre point is required
CGFloat midx = SIDELENGTH/2;
CGFloat midy = SIDELENGTH/2;
// radius of the arc
CGFloat radius = (SIDELENGTH/2) * 0.60f;
// pie background
CGContextSetFillColor(context, CGColorGetComponents([[UIColor orangeColor] CGColor]));
CGContextBeginPath(context);
CGContextMoveToPoint(context, midx + radius, midy);
CGContextAddArc(context, midx, midy, radius, radians(0), radians(360), 0);
CGContextFillPath(context);
// pie segment
CGContextSetFillColor(context, CGColorGetComponents([[UIColor blueColor] CGColor]));
CGContextBeginPath(context);
CGContextMoveToPoint(context, midx, midy);
CGContextAddLineToPoint(context, midx + radius, midy);
CGContextAddArc(context, midx, midy, radius, radians(0), radians(360 * (self.completion/100.0f)), 0);
CGContextFillPath(context);
image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
return image;
}
0
他の回答に提案されているライブラリのほかに、私が使った2つの本当に良いオープンソースのパイチャートクラスがあります。彼らは、非常にシンプルなのGitHubでそれらを見て、とても素敵に見える:
あなたが私の答えを参照することができます関連する問題
- 1. iphoneでグラフを作成する方法
- 2. CSSで円グラフを作成する方法
- 3. C#でグラフィック円グラフを作成する
- 4. 円UIPickerView(iPhone/iPad)を作成する方法は?
- 5. ggplotで浮動円グラフを作成
- 6. .netで動的円グラフを作成
- 7. コード内での円グラフの作成
- 8. Java MEで円グラフを作成するには?
- 9. MDX - icCube - 円グラフとヒストグラムの間にKnown mdxエンティティ(イベント)を作成する方法
- 10. jQPlot円グラフ - 円グラフのラベルのテキストの色を変更する方法
- 11. プラグインなしでRaphaelJS円グラフを作成する
- 12. box2dで楕円形を作成する方法は?
- 13. WPFアプリケーションで楕円形のボタンを作成する方法は?
- 14. Box2Dで「円」を作成する方法は?
- 15. chartist.js円グラフの円グラフと円のパーセンテージ
- 16. core-plotを使用して円グラフをズームインする方法は?
- 17. php + codeigniterでクエリを使用して円グラフを作成
- 18. 円グラフ(ドーナツ)グラフ
- 19. PHPで有向グラフを作成する方法は?
- 20. FlowDocumentのグラフ線で表を作成する方法は?
- 21. アンドロイドで棒グラフを作成する方法は?
- 22. Androidでこのタイプのグラフを作成する方法は?
- 23. モバイルアプリケーションのグラフ作成方法は?
- 24. Androidで手動で円グラフを描く方法は?
- 25. イメージファイルから円アイコンを作成する方法は?
- 26. Androidで3D円グラフを描画する方法
- 27. サイズ/円グラフでフォルダを表示する方法/フリーウェア
- 28. ブラックベリーアプリケーションで円グラフを表示する方法
- 29. Dundas DashBoard 2.5で円グラフの値をフォーマットする方法
- 30. xamlバインドされた色で円ボタンを作成する方法
http://stackoverflow.com/質問/ 13231244 /描画円グラフ - ios-quartz-2d/30004287#30004287円グラフを描画する単一行のコードが含まれています – iYoung