您的位置:首页 > 其它

Quartz2D简单绘制之饼状图

2011-12-04 00:23 232 查看
View Code

// 画扇形
// 红色部分
CGContextRef contextRef = UIGraphicsGetCurrentContext();
CGFloat    components[] = { 1.0f, 0.0f, 0.0f, 1.0f};
CGContextSetFillColor(contextRef, components);
CGContextMoveToPoint(contextRef, 150.0f, 150.0f);
CGContextAddArc(contextRef, 150.0f, 150.0f, 100.0f, 0 * (M_PI / 180.0f), 120 * (M_PI / 180.0f), 0);
CGContextFillPath(contextRef);
// 绿色部分
CGFloat    blueComponents[] = { 0.0f, 1.0f, 0.0f, 1.0f};
CGContextSetFillColor(contextRef, blueComponents);
CGContextMoveToPoint(contextRef, 150.0f, 150.0f);
CGContextAddArc(contextRef, 150.0f, 150.0f, 100.0f, 120 * (M_PI / 180.0f), 200 * (M_PI / 180.0f), 0);
CGContextFillPath(contextRef);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: