ios - 如何为 y 轴 iOS 图表设置字体

标签 ios fonts ios-charts

我知道我可以使用以下代码在 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 轴的字体?我尝试运行该应用程序,但字体没有任何变化。

最佳答案

它也应该在 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/

相关文章:

ios - 如何禁用 iOS 图表中饼图的旋转选项?

ios - 如何反转 UIView 或层下所有 View 的颜色?

ios - Google Nearby Messages API 破坏了应用程序图标

firefox - IE 和 Firefox 网页字体渲染问题

html - 让 Gill Sans 在 IE 中正常显示

ios - 设置条形图的顶部和底部间距 - iOS 图表

ios - 从网络获取链接 MP3

ios - 可以在导航栏中从左向右移动uilabel吗?

c - TreeView fontsize - 自定义绘制或所有者绘制

ios - 我可以在 ios-charts 中滚动图表并拖动指标​​吗?我正在使用 ios-charts 库