#pragma mark - 聊天气泡的自适应
- (void)bubblesToCalculate{
CGRect rect = [_field.text boundingRectWithSize:CGSizeMake(180, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin| NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:15]} context:Nil];
CGSize size = rect.size;
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-size.width-15, 5, size.width+15, size.height+15)];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, size.width+15, size.height+15)];
UIImage *bgImg = [UIImage imageNamed:@"bubbleSelf"];
UIImage *image = [bgImg stretchableImageWithLeftCapWidth:10 topCapHeight:10];
imageView.image = image;
[view addSubview:imageView];
UILabel *lab = [[UILabel alloc] initWithFrame:CGRectMake(5, 2, size.width, size.height+5)];
lab.font = [UIFont systemFontOfSize:15];
lab.numberOfLines = 0;
lab.text =_field.text;
view.tag = 10;
[view addSubview:lab];
[_messageArray addObject:view];
[_bgView reloadData];
_field.text = @"";
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:_messageArray.count - 1 inSection:0];
[_bgView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
[_field resignFirstResponder];
[UIView animateWithDuration:0.34 animations:^{
_inputView.frame = CGRectMake(0, self.view.frame.size.height-60, SCREEN_WIDTH, 40);
}];
[lab release];
[view release];
[imageView release];
}