iPhone UILabel - non breaking space iPhone UILabel - non breaking space ios ios

iPhone UILabel - non breaking space


Use the no-break space (\u00a0) ex: @"hello**\u00a0**world!"

post.text = [postText stringByAppendingString: @"1\u00a0hour\u00a0ago."];

U+00A0 / no-break space / Common Separator, space

from: http://en.wikipedia.org/wiki/Whitespace_character


For Swift:

let sentence = "Barcelona, Real Madryt, Juventus Turyn, Bayern Monachium"let sentencewithnbsp = String(map(sentence.generate()) {    $0 == " " ? "\u{00a0}" : $0})


In Swift 4 I had to use all caps: \U00A0

Example:

lorem ipsum some\U00A0text 1

Update Feb 2020 from the comments. Thanks to @corban:

In the Localizable.strings file it still needs to be \U00A0 - in code you have to use \u{00a0}