uchuugaka
uchuugaka

Reputation: 12782

How can I determine the minimum NSRect for drawing an attributed string?

I cannot seem to find this and hope it is a FAQ somewhere. How can I get the minimum NSRect needed to draw an NSAttributed string on OS X? I am doing an overlay borderless window, but I want to constrain the size based on what is needed to display the string.

Upvotes: 0

Views: 131

Answers (1)

Ken Aspeslagh
Ken Aspeslagh

Reputation: 11594

use NSTextContainer and NSLayoutManager. More from Apple here: https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/TextLayout/Tasks/StringHeight.html

Upvotes: 1

Related Questions