1

So that I can calculate the intrinsicContentSize of a UITextView, I'm wondering how to get all the attributes of an attributed string so I can pass them to -[NSString sizeWithAttributes:]?

ma11hew28
  • 121,420
  • 116
  • 450
  • 651

2 Answers2

-1

Dude, am I missing something here? Why not just use -[NSAttributedString size]? Also, check out UITextView NSAttributedString Size.

Community
  • 1
  • 1
ma11hew28
  • 121,420
  • 116
  • 450
  • 651
-2

You can get the attributes for the textview by getting it's attributedString and then getting the attributes of it:

NSDictionary *attrs = aTextView.attributedText.attributes


ELSE you can get the font of the textview. (if it isn't richtext, thats enough)

NSDictionary *attrs = @{NSFontAttributeName: aTextView.font };


BUT if you want the size just call boundingRectWithSize:options:context: on the attributedString you have.

Daij-Djan
  • 49,552
  • 17
  • 113
  • 135