我正在使用BNPieChart。 iPhone6s(iOS 10.2.1)中的Piechart切片丢失了,但相同的代码适用于iPhone5s(iOS 10.2.1)和iPhone5s(iOS 10.2.1)。
这是我的代码:
- (void)viewDidAppear:(BOOL)animated {
CGRect pieFrame = CGRectMake(30, 78, 240, 240);
self.chart = [[BNPieChart alloc] initWithFrame:pieFrame];
BNColor *emergencyColor = [BNColor colorWithRed:142.0/255.0 green:1.0/255.0 blue:32.0/255.0];
BNColor *urgentColor = [BNColor colorWithRed:231.0/255.0 green:133.0/255.0 blue:8.0/255.0];
BNColor *nonUrgentColor = [BNColor colorWithRed:97.0/255.0 green:147.0/255.0 blue:3.0/255.0];
self.chart.colors = [NSArray arrayWithObjects:emergencyColor,urgentColor,nonUrgentColor, nil];
[self.chart addSlicePortion:emergencyCount/totalCount withName:[NSString stringWithFormat:@"%.1f%%",(emergencyCount/totalCount)*100]];
[self.chart addSlicePortion:urgentCount/totalCount withName:[NSString stringWithFormat:@"%.1f%%",(urgentCount/totalCount)*100]];
[self.chart addSlicePortion:nonUrgentCount/totalCount withName:[NSString stringWithFormat:@"%.1f%%",(nonUrgentCount/totalCount)*100]];
[self.view addSubview:self.chart];
}
但它适用于iPhone5(iOS 10.2.1)
答案 0 :(得分:0)
实际上,需要在BNPieChart
类本身进行更改。 CGFloat
和float*
之间存在不兼容性
将BNPieChart.m
中的以下代码行替换为以下代码:
// CGFloat red, green, blue;
// [self getRGBForIndex:index red:&red green:&green blue:&blue];
要
CGFloat red, green, blue;
BNColor *color = [colors objectAtIndex:(index % [colors count])];
red = color.red;
green = color.green;
blue = color.blue;
观看viewDidAppear
以获得结果。如果有人像我一样实施了BNPieChart
,那就行得很好。