我可以在不增加行高的情况下调整 NSAttributedString 中的基线吗?
Can I adjust the baseline in an NSAttributedString without increasing the line height?
在 San Francisco 字体中,如果包围数字的括号有点低。我正在制作的应用程序中的一个示例,使用 NSAttributedString
:
我想将括号的基线增加一两个像素,但是当我使用 NSBaselineOffsetAttributeName
属性这样做时,行高也增加了两个像素。文本在 UITextView
内,我真的不想改变行高。有什么我可以做的吗?
一种可行的方法是使用 NSParagraphAttributeName
强制最大行高。
NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
[style setMaximumLineHeight:maxHeightWanted];
NSDictionary *parenthesisAttributes = @{NSParagraphStyleAttributeName:style,
NSBaselineOffsetAttributeName:@(baselineWanted),
NSFontAttributeName:sameFontWithBiggerPointSize};
在 San Francisco 字体中,如果包围数字的括号有点低。我正在制作的应用程序中的一个示例,使用 NSAttributedString
:
我想将括号的基线增加一两个像素,但是当我使用 NSBaselineOffsetAttributeName
属性这样做时,行高也增加了两个像素。文本在 UITextView
内,我真的不想改变行高。有什么我可以做的吗?
一种可行的方法是使用 NSParagraphAttributeName
强制最大行高。
NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
[style setMaximumLineHeight:maxHeightWanted];
NSDictionary *parenthesisAttributes = @{NSParagraphStyleAttributeName:style,
NSBaselineOffsetAttributeName:@(baselineWanted),
NSFontAttributeName:sameFontWithBiggerPointSize};