SOMessaging
SOMessaging copied to clipboard
Bubble with random left margin
Hi, all,
I am developing a chat app to support message bubbles appear randomly of the left margin in the table cell. I find that in SOMessageCell, the kBubbleLeftMargin and kBubbleRightMargin are defined as a fixed number. I wonder what is the best way to randomly generate these two values to make the messages appear more interesting. Is it in adjustCell?
Thank you very much!
I think you can do that in -configureMessageCell:forMessageAtIndex method.
Just try to play with origin. x of cell.containerView
Artur,
Thank you for your quick reply.
Because the cell is auto resized according to the message content, how can I calculate the origin.x with the cell width in order to avoid the fact that the left margin is so large that some text is disappeared in the right? What I mean is that how can I also obtain the real cell width according to the message content?
Thank you in advance!
在 2014年7月30日,下午2:17,Artur Mkrtchyan [email protected] 写道:
I think you can do that in -configureMessageCell:forMessageAtIndex method. Just try to play with origin. x of cell.containerView
— Reply to this email directly or view it on GitHub.
cell.containerView.frame.size.width mast return the bubble's width
Thank you again for your reply.
Now when I put
cell.containerView.frame.origin.x = 100.0;
into -configureMessageCell:forMessageAtIndex method, I have got Expression is not assignable error.
在 2014年7月30日,下午2:48,Artur Mkrtchyan [email protected] 写道:
cell.containerView.frame.size.width mast return the bubble's width
— Reply to this email directly or view it on GitHub.
You can't set view.frame.origin.x directly.
CGRect frame = cell.containerView.frame;
frame.origin.x = 100;
cell.containerView.frame = frame;
Sorry, I followed your direction, but nothing happened.
在 2014年7月30日,下午3:18,Artur Mkrtchyan [email protected] 写道:
You can't set view.frame.origin.x directly.
CGRect frame = cell.containerView.frame; frame.origin.x = 100;
cell.containerView.frame = frame; — Reply to this email directly or view it on GitHub.