boundingRectWithSize for NSAttributedString returning wrong size

Looks like you weren’t providing the correct options. For wrapping labels, provide at least:

CGRect paragraphRect =
  [attributedText boundingRectWithSize:CGSizeMake(300.f, CGFLOAT_MAX)

Note: if the original text width is under 300.f there won’t be line wrapping, so make sure the bound size is correct, otherwise you will still get wrong results.

Leave a Comment