Chat type view using UITableView and UILabel
What I want to do is create a chat type looking comment-section.
I have started with a UITableView with custom cells. And I have put a UILabel inside it.
The requirement is that I need a different color of the userName, from the actual comment text.
Now if I use 2 different labels, to ensure the textColor difference, then the comment text gets indented, as its label starts after the userName label finishes. I want the comment text to start from the starting of the cell when it g开发者_Python百科oes into 2nd line, like it is in most chat apps.
And ideas how to go around it?
If I am understanding it correctly, what you can do is use 2 labels, 1 top of another. UserName label being on top of the bigger commentText label.
The actual text of the commentText label will be the commentText appended to the text of userName label.
What that will do is, the userName label will exactly cover the area of the commentText label where the userName is there. And the userName will look like having a different color from the commentText.
精彩评论