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:]
?
Asked
Active
Viewed 1,771 times
1

ma11hew28
- 121,420
- 116
- 450
- 651
2 Answers
-1
Dude, am I missing something here? Why not just use -[NSAttributedString size]
? Also, check out UITextView NSAttributedString Size.
-
I think just `size` is kinda useless. in 99% of the cases you want to supply a constraint, no? so: I'd use `boundingRectWithSize:options:context:` – Daij-Djan Oct 12 '13 at 20:34
-
+ op has a string. not an attributed string – Daij-Djan Oct 12 '13 at 20:35
-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