Search code examples
ioscore-plot

Core Plot Title Alignment and Font Style


Is there any way an alignment can be provided for the title in Core Plot apart from setting the graph title displacement.I am having a dynamic graph title and hence the title displacement would also have to be adjusted accordingly for each case. Also is there a way to set the font Style of the title say make it Bold?


Solution

  • If the titlePlotAreaFrameAnchor and titleDisplacement don't give enough control, you can always use a Core Plot layer annotation to position your own custom title anywhere you want.

    Core Plot text styles include several properties including the font, size, color, bold, and italics. If you want the whole title to use one style, just set the title string and the titleTextStyle. If you want parts of the title to have different styles, use the attributedTitle (which takes an NSAttributedString) instead. See some of the plots in the Plot Gallery example app for sample code.