如何显示这样的核心图图例?
国家旗帜,该线下的国家名称(如图所示)

函数图(){防护字母图= hostView.hostedGraph否则{configureLegend}
let legend = CPTLegend(graph: graph)
graph.legend = legend
graph.legendAnchor = .topLeft
graph.legendDisplacement = CGPoint(x: 50.0, y: -2.0)
legend.fill = CPTFill(color: CPTColor.clear())
legend.swatchSize = CGSize(width: 10.0, height: 10.0)
legend.numberOfRows = 1
legend.entryPaddingBottom = 12
let titleStyle = CPTMutableTextStyle()
titleStyle.color = CPTColor.black()
titleStyle.fontSize = 6.0
titleStyle.fontName = Font.NissanPro_Bold
legend.textStyle = titleStyle
legend.delegate = self
}
public func legend(_ legend: CPTLegend, shouldDrawSwatchAt idx: UInt, for plot: CPTPlot, in rect: CGRect, in context: CGContext) -> Bool{
return false
}发布于 2017-08-11 20:42:46
如果你能用表情符号画旗帜,那就画吧。在标题文本中插入换行符(\n)以将文本放置在标志下。
如果需要对标志使用自定义图形,请使用图例委托并实现-legend:shouldDrawSwatchAtIndex:forPlot:inRect:inContext: delegate方法。将旗帜绘制到样例矩形内的给定图形上下文中,并返回NO以告诉图例您已经完成了所需的绘制。
若要将文本放在图形下方,请放大色板大小,然后将两者都绘制到色板矩形中。
https://stackoverflow.com/questions/45615082
复制相似问题