What is -[NSString sizeWithFont:forWidth:lineBreakMode:] good for?

后端 未结 4 1652
难免孤独
难免孤独 2020-11-28 22:51

In my question \"How do I get -[NSString sizeWithFont:forWidth:lineBreakMode:] to work?\", I learned that -[NSString sizeWithFont:constrainedToSize:lineBreakMode:]

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-28 23:31

    It sounds like it would be good for single line labels. For example, if you're drawing a string that may be truncated or have a line break, but you won't actually draw more than one line. It could still be helpful to know the exact height and width of the string, so you can position it exactly where you want it (and draw other UI items around it).

提交回复
热议问题