OGeek|极客世界-中国程序员成长平台

标题: ios - 如何为 y 轴 iOS 图表设置字体 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 10:41
标题: ios - 如何为 y 轴 iOS 图表设置字体

我知道我可以使用以下代码在 iOS 图表中设置 x 轴的字体:

myChart.xAxis.labelFont = UIFont.init(name: "AvenirNext-Regular", size: 10)!

所以,我认为我可以使用类似的代码更改 y 轴的字体,例如:

myChart.getAxis(.Right).labelFont = UIFont.init(name: "AvenirNext-Heavy", size: 10)!

但是,下面的代码没有做任何事情。是否可以更改 y 轴的字体?我尝试运行该应用程序,但字体没有任何变化。



Best Answer-推荐答案


它也应该在 y 轴上工作,我检查了 func,它已经在读取 labelFont(如果您认为这是一个错误,请在 github 上报告):

/// draws the y-labels on the specified x-position
internal func drawYLabels(context context: CGContext, fixedPosition: CGFloat, offset: CGFloat, textAlign: NSTextAlignment)
{
    guard let yAxis = yAxis else { return }

    let labelFont = yAxis.labelFont
    let labelTextColor = yAxis.labelTextColor
    ...
}

关于ios - 如何为 y 轴 iOS 图表设置字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35689235/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4