在ShinobiCharts中自定义十字准线

时间:2015-03-04 15:16:41

标签: ios swift charts shinobi

我一直在尝试在Shinobicharts中自定义工具提示,但它无法正常工作。我猜这是我添加十字准线的方式来创造问题。我最终只是想自定义工具提示的标签,因为一旦我添加了自定义十字准线样式,它就变成全黑了。

无论如何,我的代码看起来像这样:

    let crossHairStyle = SChartCrosshairStyle()
    crossHairStyle.lineColor = UIColor.whiteColor()

    let chart = ShinobiChart(frame: view.bounds)
    chart.licenseKey = ""
    chart.datasource = self
    chart.delegate = self
    chart.gestureDoubleTapResetsZoom = true
    chart.frame = CGRectMake(0, 0,width,0.9 * height)
    chart.crosshair.style = crossHairStyle
    chart.crosshair.tooltip.backgroundColor = UIColor.whiteColor()
    chart.crosshair.tooltip.label.backgroundColor = UIColor.whiteColor()
    chart.applyTheme(customTheme)

正如我所说,我无法设置标签的背景颜色,我不知道如何继续。

任何建议都将不胜感激。

1 个答案:

答案 0 :(得分:0)

我为ShinobiControls工作(就像免责声明一样)。

您看到黑框的原因是使用样式对象的十字准线工具提示。 SChartCrosshairStyle的属性在创建时初始化为nil,因此当应用于十字准线和工具提示时,样式中的任何UIColor都将是黑色的,因为当您将nil UIColor对象应用于a时会发生什么UI元素。

目前有一个错误,您无法直接在工具提示上设置颜色(这已经在本地修复,因此它应该很快就会发布)。但是,您可以使用十字准线的样式对象设置工具提示的颜色。例如:

let chart = ShinobiChart(frame: view.bounds)
chart.licenseKey = ""
chart.datasource = self
chart.delegate = self
chart.gestureDoubleTapResetsZoom = true
chart.frame = CGRectMake(0, 0,width,0.9 * height)

// Style crosshair (a style already exists on the crosshair that is pulled from the current theme being used by the chart)
chart.crosshair.style.lineColor = UIColor.whiteColor()
chart.crosshair.style.defaultBackgroundColor = UIColor.whiteColor()
chart.crosshair.style.defaultLabelBackgroundColor = UIColor.whiteColor()