Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I keep an NSTextAttachment from line-breaking?

I'm trying to set a UILabel using an NSAttributableString like so:

(x)First Item (x)Second Item (x)Third Item

Where the (x)'s represent small images loaded through NSTextAttachments. The problem is, since each (x) is an icon representing it's item, I don't want UILabel to ever break the line between the (x) and its item. I've checked that there's absolutely nothing (that I can see) between the icon and the first character of the text, but this problem even shows up in TextEdit:

Images on one line

Images on two lines

How can I always keep the text attachment on the same line as its text?

like image 246
Justin Chiumenti Avatar asked Jan 18 '26 02:01

Justin Chiumenti


1 Answers

Got it: word-joiner unicode \u2060.

like image 173
Justin Chiumenti Avatar answered Jan 19 '26 18:01

Justin Chiumenti



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!