我试图在iOS 6.x中运行它:
NSArray *n = [data allKeys];
long sc = [n count];
XYPieChart *pie = [[XYPieChart alloc] initWithFrame:CGRectMake(0, self.pieStart, 160, 220)];
[pie setDataSource:self];
[pie setDelegate:self];
[pie setStartPieAngle:M_PI_2];
[pie setAnimationSpeed:1.0];
[pie setLabelFont:[UIFont fontWithName:@"Helvetica Neue" size:11]];
[pie setLabelRadius:40];
[pie setShowPercentage:YES];
[pie setPieBackgroundColor:[UIColor colorWithWhite:0.95 alpha:1]];
[pie setPieCenter:CGPointMake(80, 100)];
[pie setUserInteractionEnabled:NO];
[pie setLabelShadowColor:[UIColor blackColor]];
pie.tag = tag;
UILabel *t = [[UILabel alloc] initWithFrame:CGRectMake(0, 2, 320, 21)];
t.textAlignment = NSTextAlignmentCenter;
[t setFont:[UIFont fontWithName:@"HelveticaNeue-Bold" size:17]];
t.text = title;
UILabel *p = [[UILabel alloc] initWithFrame:CGRectMake(71, 90, 18, 18)];
p.text = @"%";
p.backgroundColor = [UIColor whiteColor];
p.textAlignment = NSTextAlignmentCenter;
[p setFont:[UIFont fontWithName:@"HelveticaNeue-Bold" size:13]];
p.layer.cornerRadius = 9;
p.layer.masksToBounds = YES;
int vc = 35;
int lc = 31;
[pie addSubview:t];
[pie addSubview:p];
[self.myScroll addSubview:pie];
self.pieStart += 220;
[pie reloadData];
for(int i = 0; i < sc; i++){
UIView *cc = [[UIView alloc] initWithFrame:CGRectMake(162, vc, 9, 9)];
cc.backgroundColor = [self.sliceColors objectAtIndex:(i % self.sliceColors.count)];
[pie addSubview:cc];
UILabel *tl = [[UILabel alloc] initWithFrame:CGRectMake(180, lc, 134, 17)];
[tl setFont:[UIFont fontWithName:@"HelveticaNeue" size:10]];
tl.text = [self.ss objectAtIndex:i];
[pie addSubview:tl];
vc += 12;
lc += 12;
}
//NSLog(@"got here");
UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, pie.frame.size.height - 20, 320, 1)];
line.backgroundColor = [UIColor lightGrayColor];
[pie addSubview:line];
我得到的切片大小正确,它们显示在屏幕上,但百分比不是。 (它在iOS 7.1中运行良好)。
当我将[pie setShowPercentage:YES];
设置为[pie setShowPercentage:NO];
并使用:-(NSString *)pieChart:(XYPieChart *)pieChart textForSliceAtIndex:(NSUInteger)index
{
return @"test";
}
我再也没有在iOS 6.x中看到任何内容,但我在所有大片中都看到了“test”这个词。
有人可以指出我在正确的方向吗?