Ich möchte die Höhe von NSAttributedString Multiline berechnen. Es funktioniert gut für einzelne Zeile (bedeutet, es ist minus der führenden von der Höhe). Wenn der Text jedoch mehrzeilig ist, gibt er dasselbe wie eine einzelne Zeile aus.NSAttributedString Multiline mit falscher Höhe?
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);