iPhone UILabel - 不间断的空间 [英] iPhone UILabel - non breaking space

查看:203
本文介绍了iPhone UILabel - 不间断的空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在UILabel文本中使用非中断空格?

Is there a way to use non breaking spaces in UILabel text?

例如,我有2行标签和换行模式设置为自动换行。从数据库中读取此标签的内容,并将其存储为字符串。现在有时我的标签中的文字看起来像这样:

For example, I have label with 2 lines and line breaking mode set to word wrap. The content for this label is read from database, where it's stored as a string. Now sometimes my text in label looks like that:

lorem ipsum some text
1

但我想这样显示:

lorem ipsum some
text 1

所以基本上,我需要强迫'text'和'1'之间没有间隔空格。

so basicly, I need to force non breaking space between 'text' and '1'.

我找到了一些解决方案这里,但我认为在源代码文件中输入文本时它可以工作。就我而言,文本在数据库中。

I've found some solution here, but I think it could work when the text is entered in source code file. In my case the text is in database.

有什么建议吗?

推荐答案

使用不间断空格( \ u00a0)ex: @hello ** \ u00a0 ** world!

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

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

U + 00A0 /不间断空格/公共分隔符,空格

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

来自: http://en.wikipedia.org/wiki/Whitespace_character

这篇关于iPhone UILabel - 不间断的空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆