Search code examples
iphoneioscocoa-touchcore-graphicscore-text

CoreText - Spaces not wrapping?


I noticed in CoreText, in developing my own custom UITextView and also looking at Apple's SimpleTextInput, that a space or " " doesn't break (or move onto the next line) when it runs out of space at the end of the line its on. Instead, it continues to be drawn on the same line past the width bounds of the view.

Is this a bug, or is this the intended behavior? Is there anyway to get spaces to wrap / break onto the next line with CoreText?

UPDATE: Tried individually setting spaces to have kCTLineBreakByCharWrapping attribute and it didn't work. Thinking maybe there is some unicode character I could enter instead of @" " that might get it to work properly? Trying to avoid having to manually put this in the code for now.


Solution

  • I used - instead of " ", than before I draw the text I should make the place where the - is been cleaned as blank. So you can do something you like in blank space, I draw some emoji in these places, It works for me. You can try ~ ^.^