user1687717
user1687717

Reputation: 3475

How can I resize a NSTextView automatically based on the size of the contents?

I am implementing an iChat-like app, using NSTextView to display chat records. The problem is how to change the width of NSTextView automatically based on characters in it. For example, the width of NSTextView is only one character width if there's only one character in it. More than 100 characters will automatically increase the height of NSTextView.

Upvotes: 2

Views: 684

Answers (1)

user1118321
user1118321

Reputation: 26345

You can use the string addition [-NSString boundingRectWithSize:options:attributes:] to get a bounding rectangle. You might also want to look into the Layout Manager.

Upvotes: 1

Related Questions