0

I can change the font and size but I'm stuck with making text a superscript.

Here is my working code for font and size:

aVerseMutableString = NSMutableAttributedString(string: book.verseText,
    attributes: [NSFontAttributeName:NSFont(name: "Helvetica", size: 18.0)!])

Here is what I'm trying for superscript that's not working:

aVerseNumberMutableString = NSMutableAttributedString(string: verseNumber.description, 
    attributes: [NSSuperscriptAttributeName:NSNumber(1)!])

I'm not sure how to do the attributes part to create a superscript.

tazboy
  • 1,685
  • 5
  • 23
  • 39

1 Answers1

0

After using NSBaselineOffsetAttributeName I figured out how to do it the way I showed above. Here are both ways:

NSSuperscriptAttributeName

aVerseNumberMutableString = NSMutableAttributedString(string: verseNumber.description, 
     attributes: [NSSuperscriptAttributeName:NSNumber(int: 2)])

NSBaselineOffsetAttributeName

aVerseNumberMutableString = NSMutableAttributedString(string: verseNumber.description, 
     attributes: [NSBaselineOffsetAttributeName:NSNumber(double: 2.0)])
tazboy
  • 1,685
  • 5
  • 23
  • 39