Measuring the pixel width of a string

后端 未结 3 761
猫巷女王i
猫巷女王i 2020-11-29 05:45

I need to measure the pixel width of a string in Cocoa Touch. Can anyone point me to a link that explains how to do this?

3条回答
  •  南笙
    南笙 (楼主)
    2020-11-29 06:08

    Take a look at the NSString Application Kit Additions Reference, specifically boundingRectWithSize:options:attributes:. The value returned by that routine should give you the width of your NSString.

提交回复
热议问题