我可以更改字体和尺寸,但我坚持将文本作为上标。
这是我的字体和大小的工作代码:
aVerseMutableString = NSMutableAttributedString(string: book.verseText,
attributes: [NSFontAttributeName:NSFont(name: "Helvetica", size: 18.0)!])
这是我正在尝试无法使用的上标:
aVerseNumberMutableString = NSMutableAttributedString(string: verseNumber.description,
attributes: [NSSuperscriptAttributeName:NSNumber(1)!])
我不确定如何执行属性零件来创建上标。
使用nsbaselineOffSetAttributeName后,我想出了如何按照上述方式进行操作。这两种方式:
nssuperscriptattributename
aVerseNumberMutableString = NSMutableAttributedString(string: verseNumber.description,
attributes: [NSSuperscriptAttributeName:NSNumber(int: 2)])
nsbaselineOffsetAttributeName
aVerseNumberMutableString = NSMutableAttributedString(string: verseNumber.description,
attributes: [NSBaselineOffsetAttributeName:NSNumber(double: 2.0)])