4

您好想更改我的 iOS 图表的背景颜色。

我试过了:

barChartView.backgroundColor = UIColor.redcolor()

但它改变了我的条形图周围的颜色,而不是里面的颜色,即。在竖线后面。

任何想法?

4

3 回答 3

10

barChartView.backgroundColor 引用您的 BarChartView 是子视图的 UIView。您需要引用 BarChart 本身的基类来更改条形或条形后面的网格的属性。要更改栏后面空间的颜色,请尝试:

barChartView.gridBackgroundColor = UIColor.redcolor()
于 2015-09-30T15:08:53.610 回答
8

如果 Japes 回答仍然不起作用,请确保它已启用。

barChartView.drawGridBackgroundEnabled = true
于 2016-04-02T21:46:06.993 回答
2
// Set grid background color
barChartView.gridBackgroundColor = UIColor.orange

// It is required to enable 'drawGridBackgroundColor' to see effect of gridBackground color 
barChartView.drawGridBackgroundEnabled = true
于 2017-07-10T18:15:15.447 回答