-[NSAttributedString boundingRectWithSize:options:context:] ignores max width

Originator:datwelk
Number:rdar://13061608 Date Originated:22-Jan-2013 07:09 PM
Status:Open Resolved:No
Product:iPhone SDK Product Version:6.0
Classification:Serious Bug Reproducible:Always
 
Summary:
-[NSAttributedString boundingRectWithSize:options:context:] completely ignores the width constraint from its 'size' parameter. The rectangle returned by this method is exactly as wide as needed to fit all text onto one single line and is as high as the height of one line of text.

Steps to Reproduce:
1) Create an attributed string:

NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:@"aldskjf asdklfh alskdjfhals dkfhjal kseuhfdjkls hfakl jsdhflk ajsdfhlkjasdh adjshfal jsdhfakl jsdhfakl sjdhfakl sjdhflkajds adjshzfkls djhfkl asjdhfl sakjdf"];

2) Call:

CGRect rect = [attributedString boundingRectWithSize:CGSizeMake(230.0f, CGFLOAT_MAX) options:0 context:nil];

Expected Results:
The rectangle is not wider than 230.0f.

Actual Results:
The rectangle is as wide as it needs to be to render all text on one single line.

Regression:
The problem occurs as of iOS 6.0, in which this method has been introduced. Note that the problem also occurs when I use '1000.0f' instead of CGFLOAT_MAX, when I pass 'NSStringDrawingUsesFontLeading' to the options parameter or when the attributed string has attributes in place (which it hasn't in the example above).

Notes:
N/a.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!