Preventing line breaks in part of an NSAttributedString

后端 未结 3 823
一个人的身影
一个人的身影 2020-12-28 17:56

I am working on a UILabel which features large main text followed by smaller text that tells you who said it:

3条回答
  •  不知归路
    2020-12-28 18:24

    There is also word-joiner \u2060 character in Unicode which will prevent line break on its either side and is invisible. I used it to force word wrap when degree sign was part of word, so the whole word will stay on the same line, in iOS.

    Objective-C:

    text = [text stringByReplacingOccurrencesOfString:@"°" withString:@"\u2060°\u2060"];
    

提交回复
热议问题