SOMessaging icon indicating copy to clipboard operation
SOMessaging copied to clipboard

Bubble with random left margin

Open chenweiyj opened this issue 11 years ago • 6 comments

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!

chenweiyj avatar Jul 30 '14 05:07 chenweiyj

I think you can do that in -configureMessageCell:forMessageAtIndex method. Just try to play with origin. x of cell.containerView

arturdev avatar Jul 30 '14 06:07 arturdev

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.

chenweiyj avatar Jul 30 '14 06:07 chenweiyj

cell.containerView.frame.size.width mast return the bubble's width

arturdev avatar Jul 30 '14 06:07 arturdev

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.

chenweiyj avatar Jul 30 '14 06:07 chenweiyj

You can't set view.frame.origin.x directly.

CGRect frame = cell.containerView.frame;
frame.origin.x = 100; 
cell.containerView.frame = frame;

arturdev avatar Jul 30 '14 07:07 arturdev

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.

chenweiyj avatar Jul 30 '14 08:07 chenweiyj