5
NSAttributedString Multilineの高さを計算したいと思います。それは単線のためにうまく働いています(つまり、高さからリーディングを引いたものを意味します)。テキストが複数行の場合は、1行と同じになります。NSAttributedStringの複数行が不正確な高さですか?
NSMutableParagraphStyle *titleParagraphStyle = [[NSMutableParagraphStyle alloc] init];
titleParagraphStyle.lineHeightMultiple = 0.9f;
titleParagraphStyle.lineBreakMode = NSLineBreakByWordWrapping;
CGSize constrainedSize = CGSizeMake(TOUNameWidth, MAXFLOAT);
NSDictionary *attributesDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
TOUNameFont, NSFontAttributeName,
titleParagraphStyle, NSParagraphStyleAttributeName,
nil];
NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString: name attributes:attributesDictionary];
CGRect rect = [string boundingRectWithSize:constrainedSize options:NSStringDrawingUsesFontLeading context:nil];
NSLog(@"rect is %f",rect.size.height);