How to find out width of truncated UILabel text

后端 未结 2 1093
伪装坚强ぢ
伪装坚强ぢ 2021-02-06 07:20

I have UILabel, which contains dynamic text. Sometimes text is too long to be shown and thus automagically truncated. How do I find out width o

2条回答
  •  青春惊慌失措
    2021-02-06 07:45

    I don't understand why the width would be different that the width of the UILabel if the text is being truncated. Regardless, you can use sizeWithFont:constrainedToSize: to calculate the size of a string with a given font but limited to a "constraining size".

提交回复
热议问题