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

前端 未结 6 1295
旧巷少年郎
旧巷少年郎 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

    The newer NSExtendedStringDrawing category API (methods with the NSStringDrawingOptions argument) behaves in the single line mode. If you want to measure/render in multi line mode, want to specify NSStringDrawingUsesLineFragmentOrigin.

提交回复
热议问题