Changing Axis Title Font (Swift)


Both these formats are accepted but don’t work: = UIFont (name: "System Italic", size: 10) 
         yAxis.titleLabel.font =  UIFont (name: "System Italic", size: 10)
 The first one does - incoorect fonr name, as follows: = UIFont (name: "Baskerville", size: 12)
 The second, although accepted, doesn't.


Hi ehasted,

I’m not sure I quite understand the issue you’re facing.

However from doing a little bit of searching, it appears the recommended way to get an italic version of the system font is to use font descriptors:

let xAxis = SChartNumberAxis()
let fontDescriptor = UILabel().font.fontDescriptor().fontDescriptorWithSymbolicTraits([.TraitItalic]) = UIFont(descriptor: fontDescriptor, size: 30)
xAxis.title = "X Value"
chart.xAxis = xAxis

This produces the expected result - the x axis label is a larger than usual size with the font italicised.

Additionally, doing something like UIFont(name: “Baskerville”, size: 40) also meant the axis title was rendered with the expected font.

If I’ve misunderstood your issue, please let me know and I’ll take another look.

Many thanks,