*Accurately* calculating text height in Cocoa (for Mac, not iOS)

前端 未结 6 1237
一向
一向 2020-12-14 04:32

How can I calculate the height of a string within a particular label (NSTextField), for some given fixed width?

I Googled up various methods and tried this method fr

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-14 04:37

    Take a look at the NSString Application Kit Additions Reference. It seems like – sizeWithAttributes: or – boundingRectWithSize:options:attributes: could do what you want.

提交回复
热议问题