Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bubble with random left margin #21

Open
chenweiyj opened this issue Jul 30, 2014 · 6 comments
Open

Bubble with random left margin #21

chenweiyj opened this issue Jul 30, 2014 · 6 comments

Comments

@chenweiyj
Copy link

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!

@arturdev
Copy link
Collaborator

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

@chenweiyj
Copy link
Author

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 notifications@github.com 写道:

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.

@arturdev
Copy link
Collaborator

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

@chenweiyj
Copy link
Author

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 notifications@github.com 写道:

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


Reply to this email directly or view it on GitHub.

@arturdev
Copy link
Collaborator

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

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

@chenweiyj
Copy link
Author

Sorry, I followed your direction, but nothing happened.

在 2014年7月30日,下午3:18,Artur Mkrtchyan notifications@github.com 写道:

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants