http://deeryrl.blog.163.com/blog/static/1525428742011112112120767/
UIImage *bubble = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"bubble" ofType:@"png"]];
UIImageView *bubbleImageView = [[UIImageView alloc] initWithImage:[bubble stretchableImageWithLeftCapWidth:21 topCapHeight:14]];
UIFont *font = [UIFont systemFontOfSize:13];
//The following code to control the size of text string.
CGSize size = [post.content sizeWithFont:font constrainedToSize:CGSizeMake(230.0f, 1000.0f) lineBreakMode:UILineBreakModeCharacterWrap];
UILabel *bubbleText = [[UILabel alloc] initWithFrame:CGRectMake(40, 45, size.width+10, size.height+10)];
bubbleText.backgroundColor = [UIColor clearColor];
bubbleText.font = font;
bubbleText.numberOfLines = 0;
bubbleText.lineBreakMode = UILineBreakModeCharacterWrap;
bubbleText.text = post.content;
//The following code to control the size of bubble image.
bubbleImageView.frame = CGRectMake(30,5, 260.0f, size.height+95.0f);
//The following code is to set uiview size.
returnView.frame = CGRectMake(30, 5, 260.0f, size.height+95.0f);
[returnView addSubview:bubbleImageView];
[bubbleImageView release];
[returnView addSubview:bubbleText];
[bubbleText release];
如果大家有什么不懂的,可以留下问题,我们一起探讨。