我正试图在iOS 6中将一个属性字符串设置给UITextView。问题是,如果我尝试在属性字符串上设置字体属性,行间距会被忽略。但是,如果我不设置字体,而使用默认字体,则行间距正常工作。
NSString *string = @" Hello \n world";
attrString = [[NSMutableAttributedString alloc] initWithString:string];
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle defaultParagraphStyle] mutableCopy];
paragraphStyle.minimumLineHeight = 50;
// setting the font below makes line spacing become ignored
[attrString addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:20] range:NSMakeRange(0, string.length)];
[attrString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, string.length)];
mainTextView.attributedText = attrString;
有什么想法是怎么回事吗?