【发布时间】:2019-05-15 09:55:22
【问题描述】:
在我的应用程序中,我有一个托管三个散点图的 CorePlot,我还进行了如下配置,
let borderStyle = CPTMutableLineStyle()
borderStyle.lineColor = maxPlotColor
let textLayer = CPTTextLayer(text: "MAX")
textLayer.fill = CPTFill(color: .white())
textLayer.cornerRadius = 10.0
textLayer.borderLineStyle = borderStyle
maxLabelAnnotation = CPTPlotSpaceAnnotation(plotSpace: maxLinePlot.plotSpace!, anchorPlotPoint: [5, NSNumber(value: kMaxLineValue)])
maxLabelAnnotation.contentLayer = textLayer
maxLinePlot.graph?.plotAreaFrame?.plotArea?.addAnnotation(maxLabelAnnotation)
当绘图数据更新时,注释会动态更新。代码sn-p如下图,
func newData(_ theTimer: Timer) {
// MARK: Dynmic annotations
maxLabelAnnotation.anchorPlotPoint = [NSNumber(value: currentIndex - 18), NSNumber(value: kMaxLineValue)]
riskLabelAnnotation.anchorPlotPoint = [NSNumber(value: currentIndex - 18), NSNumber(value: kRiskLineValue)] }
我只想将注释粘贴在没有任何摆动的位置。任何帮助将非常感激。提前致谢。
【问题讨论】:
标签: ios swift graph annotations core-plot