我在Scrollview中创建饼图,它是主视图的子视图,然后我将pieChart添加为滚动视图的子视图,但它不显示饼图
我有以下代码
-(void)loadNews{
NSArray *graphs = [[NSArray alloc] initWithObjects:@"1", nil];
NSInteger numberofPages=[graphs count];
for (int i = 0; i < [graphs count]; i++) {
CGRect frame;
frame.origin.x = self.scrollView.frame.size.width * i;
frame.origin.y = 0;
frame.size = self.scrollView.frame.size;
UIView*subView=[[UIView alloc ]initWithFrame:frame];
[self.scrollView addSubview:subView];
//PieClass *myPieClass=[[PieClass alloc]initWithFrame:CGRectMake(250,450,320,230)];
PieClass *myPieClass=[[PieClass alloc]initWithFrame:CGRectMake(327,470,320,230)];
//myPieClass.backgroundColor=[UIColor clearColor];
myPieClass.backgroundColor=[UIColor blackColor];
myPieClass.itemArray=[[NSArray alloc]initWithObjects:valueOne,valueTwo,valueThree,valueFour, nil];
myPieClass.myColorArray=[[NSArray alloc]initWithObjects:[UIColor blueColor],[UIColor redColor],[UIColor greenColor],[UIColor brownColor], nil];
myPieClass.radius=100;
[subView addSubview:myPieClass];
}
self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * graphs.count, self.scrollView.frame.size.height);
[pageControl setNumberOfPages:numberofPages];
[pageControl setActivePageColor:[UIColor colorWithRed:36/255.0 green:71/255.0 blue:113/255.0 alpha:1.0]];
[pageControl setInactivePageColor:[UIColor lightGrayColor]];
}
答案 0 :(得分:0)
在CGRectMake中(327,470,320,230) 您正在设置327,470的原点
尝试像CGRectMake(100,100,320,230)。