UIKit's [NSString sizeWithFont:constrainedToSize:] in AppKit

前端 未结 6 1234
旧巷少年郎
旧巷少年郎 2021-01-02 22:47

Is there any equivalent method in AppKit (for Cocoa on Mac OS X) that does the same thing as UIKit\'s [NSString sizeWithFont:constrainedToSize:]?

If not

6条回答
  •  时光说笑
    2021-01-02 22:56

    Try this one:

    bounds = [value boundingRectWithSize:size options:NSLineBreakByWordWrapping | NSStringDrawingUsesLineFragmentOrigin attributes:attributes];
    

提交回复
热议问题