我可以在不增加行高的情况下调整NSAttributedString中的基线吗?
在旧金山字体中,如果围绕数字,方括号有点低。 来自我正在使用NSAttributedString
的应用程序的一个NSAttributedString
:
我想增加一个或两个像素括号的基线,但是当我这样做使用NSBaselineOffsetAttributeName
属性时,行高度也增加了两个像素。 文本是在一个UITextView
,我真的不希望线高度改变。 有什么我可以做的吗?
一种可能的方法是用NSParagraphAttributeName
强制最大行高。
NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init]; [style setMaximumLineHeight:maxHeightWanted]; NSDictionary *parenthesisAttributes = @{NSParagraphStyleAttributeName:style, NSBaselineOffsetAttributeName:@(baselineWanted), NSFontAttributeName:sameFontWithBiggerPointSize};