效果图:
工程图:
需要导入的文件:QuizChartView.h,QuizChartView.m.
代码:
RootViewController.h
#import <UIKit/UIKit.h> @class QuizChartView; @interface RootViewController : UIViewController { QuizChartView *m_chartView; } @end
RootViewController.m
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. self.title=@"饼图"; m_chartView = [[QuizChartView alloc] initWithFrame:CGRectMake(10, 70, 300, 300)]; m_chartView.backgroundColor = [UIColor orangeColor]; m_chartView.m_aPercent = [NSMutableArray arrayWithObjects:@"10",@"20",@"30",@"40",nil]; m_chartView.m_aHint = [NSMutableArray arrayWithObjects:@"早餐",@"午餐",@"晚餐",@"夜宵",nil]; [self.view addSubview:m_chartView]; }