【问题标题】:Draw a UIImage right after a multi-line NSString or NSAttributedString in UILabel在 UILabel 中的多行 NSString 或 NSAttributedString 之后绘制 UIImage
【发布时间】:2014-03-20 04:26:07
【问题描述】:

请看下图。我需要在文本之后用一个空格显示心形符号(我有一个 png)。单行文本可能很简单,但在多行情况下(如下所示)我该如何管理?请注意,这些是 UITableViewCells,我使用 UILabel 作为文本。

如果我使用表情符号字符 (♥),它在 iPhone 上始终显示为红色,与所需颜色不匹配。那么解决方案是什么?还有其他可以使用的字符代码吗?如果不是,我如何知道文本的结束 x,y 位置以便我将 png 放在那里?




【问题讨论】:

标签: ios objective-c nsstring uiimage nsattributedstring


【解决方案1】:

您可以将表情符号字符的 unicode 值附加到字符串:

label.text = [NSString stringWithFormat:@"%@ %@",yourLabelText,@"\U0001F431"];

从以下位置查找您的表情符号字符的 unicode 值:

http://apps.timwhitlock.info/emoji/tables/unicodehttp://en.wikipedia.org/wiki/Emoji

【讨论】:

  • 他在问题中说他不想使用表情符号,因为颜色。
  • 是的,这不是解决方案。 :(
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-05-04
  • 2014-04-09
  • 1970-01-01
  • 2011-09-07
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多