我需要在文本视图中对一些(但不是全部)文本行进行水平居中。我尝试用一个NSParagraphStyleAttributeName实例来设置NSParagraphStyle实例,该实例的alignment属性是要居中的行范围内的NSTextAlignmentCenter我也设置字体,所以中心线是粗体。当我使用下面的代码这样做时,相关的行是粗体的,但保持左对齐。[attributedString setAttributes:attributes range
我创建了一个对齐的NSMutableAttributedString,如下所示:/// Make a copy of the default paragraph style
NSMutableParagraphStyle *paragraphStyle = [[NSParagraphStyleNSMutableAttributedString alloc] initWithString:text