简体   繁体   中英

Draw a UIImage right after a multi-line NSString or NSAttributedString in UILabel

Please see image below. I need to show heart symbol (that I have as a png) right after the text with one space. It may be simple in single line text but in multi-line case (as shown below) how can I manage this? Please note that these are UITableViewCells and I am using UILabel for text.

If I use Emoji character (♥) it always displays in Red on iPhone which doesn't match the required color. So what's the solution? Is there some other character code that can be used? If not how will I know the ending x,y position of text so that I place png there?




在此处输入图片说明

You can append the append the unicode value for your emoji character to the string :

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

find unicode value for your emoji character from :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM