Ios swift集合图像中心饼图

Ios swift集合图像中心饼图,ios,swift,charts,Ios,Swift,Charts,现在我使用Charts 我想将图像添加到图表的中心,而不是饼图 我该怎么办 代码 func updatePieChart(){ let track=[“”,“”] 让钱来=[65,45] 变量条目=[PieChartDataEntry]() 用于货币的(指数、值)。枚举(){ let entry=PieChartDataEntry() entry.y=双精度(值) entry.label=曲目[索引] 条目。追加(条目) } let set=PieChartDataSet(值:条目,标签:“饼

现在我使用
Charts

我想将图像添加到图表的中心,而不是饼图

我该怎么办

代码

func updatePieChart(){
let track=[“”,“”]
让钱来=[65,45]
变量条目=[PieChartDataEntry]()
用于货币的(指数、值)。枚举(){
let entry=PieChartDataEntry()
entry.y=双精度(值)
entry.label=曲目[索引]
条目。追加(条目)
}
let set=PieChartDataSet(值:条目,标签:“饼图”)
变量颜色:[UIColor]=[]
对于0..中的uuu,请尝试以下方法:

let attachment = NSTextAttachment()
attachment.image = UIImage(named: "your image")
let attachmentString = NSAttributedString(attachment: attachment)
let labelImg = NSMutableAttributedString(string: "")
labelImg.append(attachmentString)

pieChartView.centerAttributedText = labelImg
试试这个

@IBOutlet weak var chartView: PieChartView!
@IBOutlet weak var image: UIImageView!
...

image.center = chartView.center
@IBOutlet weak var chartView: PieChartView!
@IBOutlet weak var image: UIImageView!
...

image.center = chartView.center