4
如何顯示這樣的coreplot圖例?Coreplot傳說中的標題,國家標籤,並在該行下迅速
國家標誌,根據該線(圖中的相似)
FUNC configureLegend()國名{ 後衛讓圖形= hostView.hostedGraph其他{}回報
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
}
感謝您的回覆Eric。但是,上述實現做了什麼。該線條向下移動(而不是中心),而不是在標誌和文字下 – Marios
您不必使用圖例。使用Core Plot邊框圖層(標誌圖形可以是其中一個圖層的「填充」)和文本圖層來構建您想要的視圖。將此圖層層次結構作爲註釋附加到圖形上。 –